| I agree with you about the awfulness of using such a key, especially that it seems a kind of business key, which is hard to maintain as a primary key, I've posted my answer there as a first solution, and it matches what what you've said, BUT, what I'm talking about is that such a key is permitted (I can't see any restriction in JPA Spec and Hibernate Guide, for using a String as a PK), as it's, EntityManager should reflect what I have in a database, It seems like EntityManager.Find does not assign the found value, but it uses the argument value instead, however Using a Select...Where statement With EntityManager.CreateQuery respects it. Plus, All EntityManager.Find states that It returns "the found entity instance or null if the entity does not exist", so a found entity should have the same EXACT value as in the database, as it may be critical for business rules Note: I have planned to look for some time to contribute to this issue (If you decide to reoppen it). |