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, 2022 in Java by Rahul
• 9,680 points
10,348 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, 2022 by Aditya
• 7,680 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,640 points
34,805 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
2,628 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,920 points
17,285 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,190 points
980 views
+1 vote
1 answer
0 votes
0 answers
0 votes
0 answers

resource : Invocation of init method failed

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

May 16, 2022 in Java by Kichu
• 19,040 points
3,372 views
0 votes
0 answers
0 votes
1 answer

How do I resolve the "java.net.BindException: Address already in use: JVM_Bind" error?

If you are aware about what port ...READ MORE

answered Feb 22, 2022 in Java by Aditya
• 7,680 points
5,144 views
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, 2022 in Java by Aditya
• 7,680 points
2,153 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP