Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: "not-null property references a null or transient value" only with HSQL

 
Alvaro Victor Cavalcanti
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have an already release software that makes use of Hibernate+Postgre, and now I have to make it compatible ALSO with HSQL.

All in all, I managed to get everything working, except the following issue. I have a Product and a ProductDetail entities. And the latter has a reference to the former and everything works like a charm on Postgre. When I create a product (and proddetails) the Hibernate can save them. But when I use the HSQL, it flops:

not-null property references a null or transient value: xx.xxx.xxxx.product.ProductDetail.product

But the thing is, I've inspected the entity on the line:

HibernateUtil.getSession().saveOrUpdate(entity);

And it is a ProductDetail, and its product field IS NOT EMPTY. It contains a valid Product object. And that is no surprise, as I've already written it works with Postgre.

Any clues?

 
Manuel Petermann
Ranch Hand
Posts: 177
Hibernate Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we need your mapping for the entities related to your problem.
Maybe you are trying to save an unsaved entity and you forgot a cascade.
 
Alvaro Victor Cavalcanti
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that's the problem, since it works with Postgres. But here it goes (some parts were ommited due to confidentiality):

ProductDetail.hbm.xml


Product.hbm.xml
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic