Org.hibernate.PersistentObjectException:detached entity passed to persist this exception has occurred:

Source: Internet
Author: User

Exception information: caused by:org.hibernate.PersistentObjectException:detached entity passed to Persist:com.xxx.Xxx

Simply put, this exception occurs when a free object is to be persisted (save), whose ID is both the ORM framework generates an ID value for it, and the ID of this entity already has a value.

The solution is many, the author is to do a property editor for its entity, in the editor to determine whether the primary key ID is empty and the length is 0, if so, then place a null. Checking the ID before saving is also a workaround.

Sometimes in a one-to-one, one-to-many save, this is also the case for the associated party, so the key check ID field is available.

Org.hibernate.PersistentObjectException:detached entity passed to persist this exception has occurred:

Related Article

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.