aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate Made Easy Tuturial: CascadeType.PERSIST not working (but ALL does) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Made Easy Tuturial: CascadeType.PERSIST not working (but ALL does)" Watch "Hibernate Made Easy Tuturial: CascadeType.PERSIST not working (but ALL does)" New topic
Author

Hibernate Made Easy Tuturial: CascadeType.PERSIST not working (but ALL does)

Klaas van Gelder
Ranch Hand

Joined: Jul 08, 2004
Posts: 100
Hello,
I am making progress with the tutorial, but encounter a new problem in chappter 17.
The example uses 2 classes, Exam and ExamDetail in a OneToOne relation. The example works when I touch both objects with the Hibernate Session.
But using the cascade function, I added the CascadeType.PERSIS annotation:


But I get the TransientObjectException.
Even when I list all the values as shown on page 327, I still get the exception.


However, using the value ALL works fine!
Of course the use of ALL is what we sould normally do but I wonder why PERSIST of even the full list of values generate the exception.
Grtz, Klaas

"What you don't know, can't help you"
SCJP (81%), SCWCD (81%), SCJD (354/400), SCBCD (85%)
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Okay, this appears to be the morning's "Brain Teaser"

What's the main method. Let us look at it. I'm sure the answer lies within.
Klaas van Gelder
Ranch Hand

Joined: Jul 08, 2004
Posts: 100
My main method is prety straightforward... of course I eliminated the call for saving the Details object to test the cascade funcitonality.


For al clarity: I use the same main method for each test, but it only works with the cascadetype set to ALL and not for PERSIST or even the list of all possible values...
And excuse me for the wrong title of the thread, I meant PERSIST instead of REFRESH...
Mael Sicsic
Greenhorn

Joined: Jun 08, 2011
Posts: 1
Hi,
Have you found a solution to your problem ? I have the same cascading problem with a ManyToMany relation annoted with PERSIST and MERGE.
When the relation is annoted with ALL, the cascading works fine during save, however with PERSIST and MERGE I have the same transient exception you had.

Mael
 
 
subject: Hibernate Made Easy Tuturial: CascadeType.PERSIST not working (but ALL does)