属性 jpa 引用异常
Property reference exception with jpa
我是 spring 数据 jpa 的新手并尝试使用它,但遇到 org.springframework.data.mapping.PropertyReferenceException 的问题:未找到类型用户的 属性 名称!
有人可以建议我可以做什么吗?我正在苦苦挣扎,但找不到解决方案
**Service**
public interface UserService {
Page<User> findAllUsers();
}
**Service Impl** where I am trying to implement the service methods
@Service("userService")
@Transactional
public class UserServiceImpl implements UserService{
/*@Autowired*/
@Qualifier("userDao")
private final UserDao dao;
@Autowired
public UserServiceImpl(UserDao dao) {
this.dao = dao;
}
private static final AtomicLong counter = new AtomicLong();
private static List<User> users;
public Page<User> findAllUsers() {
return dao.findAll(pageRequest);
}
**DAO**
public interface UserDao extends JpaRepository<User, Long> {
}
**User**
@Entity
@Table(name="USERAG")
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "users_seq")
private long id;
@Column(name = "NAME", nullable = true)
private String username;
@Column(name = "ADDRESS", nullable = true)
private String address;
@Column(name = "EMAIL", nullable = true)
private String email;
我认为您删除了 DAO 方法。我好像记得你在 "name" 有过订单。您的实体没有 "name",而是 "username"。简而言之,它在您的实体(您没有)上寻找 "name"
我是 spring 数据 jpa 的新手并尝试使用它,但遇到 org.springframework.data.mapping.PropertyReferenceException 的问题:未找到类型用户的 属性 名称! 有人可以建议我可以做什么吗?我正在苦苦挣扎,但找不到解决方案
**Service**
public interface UserService {
Page<User> findAllUsers();
}
**Service Impl** where I am trying to implement the service methods
@Service("userService")
@Transactional
public class UserServiceImpl implements UserService{
/*@Autowired*/
@Qualifier("userDao")
private final UserDao dao;
@Autowired
public UserServiceImpl(UserDao dao) {
this.dao = dao;
}
private static final AtomicLong counter = new AtomicLong();
private static List<User> users;
public Page<User> findAllUsers() {
return dao.findAll(pageRequest);
}
**DAO**
public interface UserDao extends JpaRepository<User, Long> {
}
**User**
@Entity
@Table(name="USERAG")
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "users_seq")
private long id;
@Column(name = "NAME", nullable = true)
private String username;
@Column(name = "ADDRESS", nullable = true)
private String address;
@Column(name = "EMAIL", nullable = true)
private String email;
我认为您删除了 DAO 方法。我好像记得你在 "name" 有过订单。您的实体没有 "name",而是 "username"。简而言之,它在您的实体(您没有)上寻找 "name"