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.
Repository:
Domain:
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)
Code:
@Repository("userDao")
public interface UserDao extends CrudRepository<User, Long> {
public User findByUserName(String userName);
}
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();
}