How to fix the Hibernate object references an unsaved transient instance - save the transient instance before flushing error

0 votes

I receive following error when I save the object using Hibernate:-

object references an unsaved transient instance - save the transient instance before flushing

Feb 18 in Java by Rahul
• 8,980 points
58 views

1 answer to this question.

0 votes
You should include cascade="all" while using XML or cascade=CascadeType.ALL while using annotations on your collection mapping. This happens because you have a collection in your entity, and that collection has one or more items which are not present in the database. By specifying the above options you tell hibernate to save them to the database when saving their parent.
answered Feb 18 by Aditya
• 7,280 points

Related Questions In Java

0 votes
1 answer

object references an unsaved transient instance - save the transient instance before flushing

You should add cascade="all" (if using xml) ...READ MORE

answered Sep 26, 2018 in Java by Parth
• 4,630 points
29,594 views
0 votes
1 answer

How to fix the error failed to load the JNI shared Library?

You need these three things : 64-bit OS 64-bit ...READ MORE

answered Apr 19, 2018 in Java by sophia
• 1,400 points
1,732 views
0 votes
2 answers

How do I read and convert an InputStream object to string type?

You can also use Java Standard Library ...READ MORE

answered Jul 17, 2018 in Java by Sushmita
• 6,900 points
14,489 views
0 votes
1 answer

How to get the number of digits in an int?

You can find out the length of ...READ MORE

answered May 14, 2018 in Java by Akrati
• 3,170 points
399 views
0 votes
0 answers
0 votes
0 answers

resource : Invocation of init method failed

I am getting this error when I ...READ MORE

6 days ago in Java by Kichu
• 16,250 points
23 views
0 votes
1 answer
0 votes
1 answer

jQuery fix for "Uncaught TypeError: $ is not a function" error

 Use the following lines of code in ...READ MORE

answered Feb 16 in Java by Aditya
• 7,280 points
63 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP