-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: NPE on persist
PostPosted: Wed Jun 05, 2013 4:07 am 
Newbie

Joined: Tue Sep 21, 2004 3:47 am
Posts: 8
Hi,

I get the following exception when I call em.persist(myObj):

java.lang.NullPointerException
at org.hibernate.type.descriptor.java.AbstractTypeDescriptor.extractHashCode(AbstractTypeDescriptor.java:88)
at org.hibernate.type.AbstractStandardBasicType.getHashCode(AbstractStandardBasicType.java:210)
at org.hibernate.type.AbstractStandardBasicType.getHashCode(AbstractStandardBasicType.java:214)
at org.hibernate.type.EntityType.getHashCode(EntityType.java:352)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:263)
at org.hibernate.engine.spi.EntityKey.generateHashCode(EntityKey.java:114)
at org.hibernate.engine.spi.EntityKey.<init>(EntityKey.java:79)
at org.hibernate.internal.AbstractSessionImpl.generateEntityKey(AbstractSessionImpl.java:247)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:172)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:135)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:78)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:208)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:151)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:78)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:853)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:827)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:831)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:875)
at...

There are 2 entities have a relationship one to one by an id.
I am using hibernate 4.2.1 with JPA 2 on JBoss 7.1.

Any idea?


Top
 Profile  
 
 Post subject: Re: NPE on persist
PostPosted: Wed Jun 05, 2013 9:34 pm 
Beginner
Beginner

Joined: Sun Jan 11, 2009 2:47 pm
Posts: 21
You did not post enough information.

Does the answer here help: http://stackoverflow.com/questions/6744451/hibernate-nm-extracthashcode-throws-nullpointerexception


Top
 Profile  
 
 Post subject: Re: NPE on persist
PostPosted: Thu Jun 06, 2013 2:05 am 
Newbie

Joined: Tue Sep 21, 2004 3:47 am
Posts: 8
Thanks you hit the point. I quite new with hibernate and JPA and the object structure is much more complex like in the examples I have seen. I have to persist the references entities in a strict order and then it is working. I would have expected that em.persist(rootObject) would be enough and the JPA annotation are sufficient for the automatic storage.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.