wood burning stoves 2.0*
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


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "OneToOne : TransientObjectException" Watch "OneToOne : TransientObjectException" New topic
Author

OneToOne : TransientObjectException

Carlos Conti
Ranch Hand

Joined: Apr 21, 2010
Posts: 113
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:

Proveedor.class
---------------------

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

ComercialOfertas.class
----------------------------
@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.
Carlos Conti
Ranch Hand

Joined: Apr 21, 2010
Posts: 113
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.

Carlos.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OneToOne : TransientObjectException