Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:44:04+00:00 2026-06-16T00:44:04+00:00

I have a spring mvc 3.1 application based on this tutorial . I’ve modified

  • 0

I have a spring mvc 3.1 application based on this tutorial. I’ve modified the application to an annotation based application and adapted the view handler to use InternalResourceViewResolver over jstl which is working fine.

In a nutshell the app uses spring mvc, spring data jpa and jqgrid to produce a simple user list which has basic crud mappings passing actions to the controllers through the response …

When I attempt to modify a record by an update action I’m getting 500 errors (aop trace interceptor ) …

Exception …

    Servlet.service() for servlet [dispatcher] in context with path    
    [/spring-jqgrid-tutorial] threw exception [Request processing failed;    
    nested exception is org.springframework.dao.InvalidDataAccessApiUsageException:
    org.hibernate.QueryParameterException: 
    Position beyond number of declared ordinal parameters.    
    Remember that ordinal parameters are 1-based! 
    ...
    at org.beckett.service.UserService.update(UserService.java:32)

UserService …

    ...   
public Boolean update( User user ) {
    User existingUser = repository.findByUsername( user.getUsername() );
    if( existingUser == null ) {
        return false;
    }
    // Only firstName, lastName, and role fields are updatable
    existingUser.setFirstName( user.getFirstName() );
    existingUser.setLastName( user.getLastName() );
    existingUser.getRole().setRole( user.getRole().getRole() );

    User saved = repository.save( existingUser );
    if( saved == null )
        return false; {

    }
    return true;
}

    ...

User Entity

    @Entity( name = "user" ) 
    @NamedQuery( name = User.FIND_BY_USERNAME, 
    query = "select u from user u where u.username = :username" )
    public class User {

    public static final String FIND_BY_USERNAME = "User.findByUsername";

    @Id @GeneratedValue( strategy = GenerationType.AUTO )
    private Long id;

    private String firstName;
    private String lastName;

    @Column( unique = true )
    private String username;

    @JsonIgnore
    private String password;

    @OneToOne( cascade =  CascadeType.ALL, mappedBy = "user" )
    private Role role;
...

UserRepository

    public interface UserRepository extends JpaRepository<User, Long> {

    User findByUsername( String username );

    Page<User> findByUsernameLike( String username, Pageable pageable );

    Page<User> findByFirstNameLike( String firstName, Pageable pageable );

    Page<User> findByLastNameLike( String lastName, Pageable pageable );

    Page<User> findByFirstNameLikeAndLastNameLike( String firstName, String lastName, Pageable pageable );

    @Query( "select u from user u where u.role.role = :role" )
    Page<User> findByRole( @Param( "role" ) Integer role, Pageable pageable );
}

UserController

    @RequestMapping( value = "/update", 
    produces = "application/json", 
    method = RequestMethod.POST )

    public @ResponseBody StatusResponse update( 
           @RequestParam String username, 
           @RequestParam String firstName, 
           @RequestParam String lastName, 
           @RequestParam Integer role ) {

       User existingUser = new User( username, firstName, lastName, new Role( role ) );
       Boolean result = service.update( existingUser );
       return new StatusResponse( result );
}

I’ve seen several threads regarding this exception stating the requirement to change the HQL Query … However, I’m not sure how to go about debugging this issue …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:44:05+00:00Added an answer on June 16, 2026 at 12:44 am

    This was solved by replacing the named parameter with a positional parameter for the Named Query ..

        @NamedQuery( name = User.FIND_BY_USERNAME, 
        query = "select u from user u where u.username = ?1" )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a localized spring mvc based web application, that has an externalized messages
I have a Spring MVC application which uses FreeMarker as View technology (But maybe
I have a Spring MVC application trying to use a rich domain model, with
I have a REST web service built with Spring MVC, with annotation-based configuration and
I have a Spring MVC based Web Application with Hibernate. Following is the directory
I have an Entity Framework based MVC application linked to a SQL server. This
I have a Spring MVC based web application. There are many custom tags written
I am developing a spring mvc based application. I have a simple pojo form
I have a spring mvc application that I have broken up into separate maven
I have a Spring Web MVC application that I'd like to serve a large,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.