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

Source: Internet
Author: User
Exception 1:not-null property references a null or transient value
WORKAROUND: Set the "one" side of the "one-to-many" relationship to Not-null to False
(Reference: http://www.thearcmind.com/confluence/pages/viewpage.action?pageId=212)

Abnormal 2:org.hibernate.transientobjectexception:object references an unsaved transient instance
Workaround: cascade= "Save-update,persist"
(Reference: http://www.laliluna.de/254.html)

Exception 3:org.hibernate.queryexception:could not resolve property
Workaround: "From Category Category where Category.userid =: UserID" modified to "from Category Category =: Whereuserid" or "from UserID" Gory category where Category.user.id =: UserID "
(Reference: http://www.laliluna.de/277.html)

Exception 4:could not initialize Proxy-the owning sessions was closed
Workaround: Set lazy to False

(Reference: http://forum.springframework.org/showthread.PHP?t=27993)


Org.hibernate.TransientObjectException:object references an unsaved transient instance-save the transient instance befo Re Flushing:

This is primarily encountered when manytoone cascading operations, such as a new object, which was saved in a new object (i.e., not a persistent state) before it was saved.

The solution is to isolate the object (this is a persistent state) before saving or updating it.

The solution is to set the Many-to-one cascade to: Cascade= "Save-update,persist"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.