JPA Hibernate saving an Entity doesn't work in Intellij Plugin



I wrote a Library that utilizes JPA with a Hibernate distribution. Within that Library there is an Entity Class using a Key Class as Identifier. The Key Class consists of two Strings (uuid, hash) which are encoded as varchar 36 and varchar 64 in the DB. 

When i start the Library as cmd programm I can read and write my entities to the DB without any problems.

Now when i include the Library in my Intellij Plugin I still can read all Entities from the DB without problems but as soon as I try to save one to the DB I get following error Message 

org: hibernate.HibernateException: identifier of an instance of Entity was altered from EntityKey@cb63e3d2 to EntityKey@54fdb443

I do not change the Key what so ever and again the same code works fine when run as cmd programm without the Intellij context. 

Here a simplified version of my code that still produces the same exception: 

try {
EntityKey key = new EntityKey("1111", "1111");
Entity a = em.find(Enttiy.class, key);
} catch (Exception e) {

The Exception is thrown at the .commit() line. Meaning the key still works to read the Entity but fails at saving.

Any idea why this doesnt work in the Intellij context and how I can fix this.

1 comment

I'd suspect that is due to some internal magic how JPA works. Maybe another classloading issue.


Please sign in to leave a comment.