-->
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.  [ 1 post ] 
Author Message
 Post subject: object.getId() returns null. (JPA)
PostPosted: Fri Jul 20, 2012 4:33 am 
Newbie

Joined: Fri Jul 20, 2012 4:19 am
Posts: 1
Hi guys.

I'm using a Class call Boom that is persisted using JPA. I have also written DAO classes that implement database access methods for that class.
I also use transactions (EJB stateless session beans) to access the dao classes.

One problem that I have been facing is that findById(Long id) returns a not null object, but when I call getId() on that object, it returns null. A little precision, I have declared the id with nullable = false within the Boom class.
The most surprising is the fact that, when I call toString() on the return object, the ID is set while at the same time object.getId() returns null.

For example:

Boom object = this.getBoomDAO().findById(anId);
System.out.println(object.getId());
System.out.println(object.toString());


Output:
null
1023

Best regards.


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

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.