Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I am getting null value for particular column, while loading the object.

 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an entity bean which is made using Hibernate annotation.




so, whenever I save the particular POJO, it's get saved into the table properly. Here id is Autogenerated value and dElementId is Primary key.
now, once I save and then try to load the particular entity from DB, i get value of id as null but do get proper value of dElementId.

Now, my question is why I am getting null value for id colum though it has proper value in table. I am commiting the transaction as well as flushing the transaction too, but did not help. Remember as soon as I save the object, I am trying to retrieve the object, because I need id value.



 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your id field is autogenerated but you have @Id annotation on the dElementId field??
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is because, DAElementID is primary key in database..hence...ID is is sequence generated value....
Please let me know opinion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic