Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Query method declaration can not be parsed correctly

$
0
0
There is an error occurred when application context initializing, I do not know what is the problem, could someone tell me why? thanks a lot.

Code:

Caused by: java.lang.IllegalArgumentException: Unable to resolve attribute [userName] against path
        at org.hibernate.ejb.criteria.path.AbstractPathImpl.unknownAttribute(AbstractPathImpl.java:120)
        at org.hibernate.ejb.criteria.path.AbstractPathImpl.locateAttribute(AbstractPathImpl.java:229)
        at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:200)
        at org.springframework.data.jpa.repository.query.QueryUtils.toExpressionRecursively(QueryUtils.java:408)
        at org.springframework.data.jpa.repository.query.JpaQueryCreator$PredicateBuilder.build(JpaQueryCreator.java:197)
        at org.springframework.data.jpa.repository.query.JpaQueryCreator.toPredicate(JpaQueryCreator.java:144)
        at org.springframework.data.jpa.repository.query.JpaQueryCreator.create(JpaQueryCreator.java:86)
        at org.springframework.data.jpa.repository.query.JpaQueryCreator.create(JpaQueryCreator.java:44)

Repository:
Code:

@Repository("userDao")
public interface UserDao extends CrudRepository<User, Long> {
       
        public User findByUserName(String userName);
}

Domain:
Code:

@Entity
@Table(name = "T_USER")
public class User implements Persistable<Long> {

        private static final long serialVersionUID = -8549228842877928873L;

        @Id
        //@SequenceGenerator(name="userSeq",sequenceName="SEQ_USER")
        //@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="userSeq")
        @GeneratedValue(strategy=GenerationType.AUTO)
        @Column(name="ID")
        private Long _id;
       
        @Column(name="USER_NAME")
        private String _userName;
       
        @Column(name="PASSWORD")
        private String _password;
       
        public String getUserName() {
                return _userName;
        }
        public void setUserName(String userName) {
                _userName = userName;
        }
        public String getPassword() {
                return _password;
        }
        public void setPassword(String password) {
                _password = password;
        }
       
        @Override
        public Long getId() {
               
                return _id;
        }
       
        @Override
        public boolean isNew() {
                return null == getId();
        }


Viewing all articles
Browse latest Browse all 297

Trending Articles