File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes OneToOne : TransientObjectException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "OneToOne : TransientObjectException" Watch "OneToOne : TransientObjectException" New topic

OneToOne : TransientObjectException

Carlos Conti
Ranch Hand

Joined: Apr 21, 2010
Posts: 112
Hi all,

I have been struggling for hours now with this really surprising issue. I never had problems with this sort of things. Classes involved are Proveedor (Supplier) and ComercialOfertas (Commercial). This is a OneToOne relationship:


@OneToOne(cascade=CascadeType.ALL) @JoinColumn(name="comercial_ofertas_id") @Valid ComercialOfertas comercialOfertas = null;

@OneToOne(cascade=CascadeType.ALL,mappedBy="comercialOfertas") Proveedor proveedor = null;

getters/setters are compliant with JavaBeans notations and column names are fully correct in the database. I also check that both references are set correctly at the time of saving, and they are.

Currently this is done in a dev stage of my project and I can remember saving such instances with no problem. Now this is arising for some reason.

Have tried as well by catching the exception and digging down the exception information trying to clue something out. But have had no luck.

Would very much appreciate if anyone sees anything which may be disturbing the process.

Thank you very much.

Carlos Conti
Ranch Hand

Joined: Apr 21, 2010
Posts: 112
Solved, but the problem was not this relationship, but another ManyToMany relationship between ComercialOfertas and another class in my domain. However the exception was arosen from ComercialOfertas. That was what drove me mad.
After enabling show_sql I saw something was wrong there, then the sql stats stopped when trying to insert records in the join table describing that manytomany relationship. The answer was to cascade (as usual with this type of exception) from one entity to another. The whole point is that the true error got masked and was very difficult to see.

Thanks anyway.

It is sorta covered in the JavaRanch Style Guide.
subject: OneToOne : TransientObjectException
Similar Threads
Hibernate association mapping
JPA2.0 CascadeType.ALL doesn't cascade persist
mapping One-to-many relationships using NetBeans and Not Hibernate
problem preventing initialization associated entity
EJB 3.0 - Error while persisting one-one unidirectional relation