-->
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.  [ 2 posts ] 
Author Message
 Post subject: NullPointerException and #getReference
PostPosted: Sat Feb 09, 2013 7:41 pm 
Newbie

Joined: Mon Jan 14, 2013 4:07 pm
Posts: 17
Any ideas why I would be experiencing flakiness with #getReference? Under some circumstances I can get an NPE when calling the methods of the object returned by #getReference. For example, I can run a unit test over and over and sometimes I will get an NPE and sometimes not.

If I use #find or #merge instead everything seems to be fine. Here's an example:

Code:
entityToOperateOn = em.getReference( MyEntity.class, anEntityPossiblyFromAnotherTransaction.getId() );


Sometimes when I call #getId on the entity to operate on I will get an NPE. If I change #getReference to #find or #merge it always works. Note that this is not deterministic, the failure only happens sometimes on the same exact code paths. Any pointers on what I should start looking into to resolve this?

TIA!


Top
 Profile  
 
 Post subject: Re: NullPointerException and #getReference
PostPosted: Tue Feb 12, 2013 3:48 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
As first thing you could report the stacktraces of your NPE's and tell which version of hibernate you are using.
Otherwise it is difficult to help you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.