나는 다음과 같은 정수 ID 필드 단순한 객체가 누락되었습니다JPA에 의해 검색된 객체의 ID는
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(unique = true, nullable = false)
private int id;
객체가 제대로 데이터베이스에 지속 할 수 있습니다. 하여 데이터베이스에서 객체를 검색 할 때, : 검색된 객체의
EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("MyService");
EntityManager entityManager = emFactory.createEntityManager();
MyObject myObject = entityManager.find(MyObject.class, 1);
entityManager.close();
ID 필드를 항상 0이지만, 다른 모든 필드의 값은 올바르게 검색됩니다.
@Id 주석을 코드에서 제거하면 다른 모든 필드와 마찬가지로 id 필드의 값을 올바르게 검색 할 수 있습니다.
MS SQL Server 2008에서 OpenJPA를 사용하고 있습니다. MS sqljdbc 드라이버와 JTDS 드라이버가 테스트되었습니다.
은 버그입니다. – Bozho