Skip to main content
added 1 character in body
Source Link
Stephen Paul
  • 39.4k
  • 18
  • 99
  • 76

I just got this error because I was settingassigning an un-proxied entity don'tonto another entity before saving.

I should have been linking a proxied entity instance.

See the below explanation:

Child saved = childRepository.save(child); // INCORRECT parent.setChild(child); // <-- 'child' is NOT managed (not proxied) // CORRECT parent.setChild(saved); // <-- 'saved' is managed (proxied) 

I just got this error because I was setting an un-proxied entity don't another entity before saving.

I should have been linking a proxied entity instance.

See the below explanation:

Child saved = childRepository.save(child); // INCORRECT parent.setChild(child); // <-- 'child' is NOT managed (not proxied) // CORRECT parent.setChild(saved); // <-- 'saved' is managed (proxied) 

I just got this error because I was assigning an un-proxied entity onto another entity before saving.

I should have been linking a proxied entity instance.

See the below explanation:

Child saved = childRepository.save(child); // INCORRECT parent.setChild(child); // <-- 'child' is NOT managed (not proxied) // CORRECT parent.setChild(saved); // <-- 'saved' is managed (proxied) 
added 28 characters in body
Source Link
Stephen Paul
  • 39.4k
  • 18
  • 99
  • 76

I just got this error because I was setting an un-managed, un-proxied beanentity don't another entity before saving.

I should have been linking a proxied entity instance.

See the below explanation:

Child saved = childRepository.save(child); // INCORRECT parent.setChild(child); // <-- 'child' is NOT managed (not proxied) // CORRECT parent.setChild(saved); // <-- 'saved' is managed (proxied) 

I just got this error because I was setting an un-managed, un-proxied bean.

I should have been linking a proxied entity instance.

See the below explanation:

Child saved = childRepository.save(child); // INCORRECT parent.setChild(child); // <-- 'child' is NOT managed (not proxied) // CORRECT parent.setChild(saved); // <-- 'saved' is managed (proxied) 

I just got this error because I was setting an un-proxied entity don't another entity before saving.

I should have been linking a proxied entity instance.

See the below explanation:

Child saved = childRepository.save(child); // INCORRECT parent.setChild(child); // <-- 'child' is NOT managed (not proxied) // CORRECT parent.setChild(saved); // <-- 'saved' is managed (proxied) 
Post Undeleted by Stephen Paul
deleted 163 characters in body
Source Link
Stephen Paul
  • 39.4k
  • 18
  • 99
  • 76

I just got this error where two entities referenced each other via a @OneToOne mappingbecause I was setting an un-managed, un-proxied bean.

Using the @transient instructs the ORM not to persist that propertyI should have been linking a proxied entity instance.

NOTE that inSee the below example the child is the one with the foreign key to the parent.explanation:

public class Child { saved = @OneToOnechildRepository.save(child);  private Parent parent;  // INCORRECT parent.setChild(child); // <-- ORM'child' shouldis persistNOT asmanaged usual }(not proxied) public class Parent// {CORRECT  @OneToOneparent.setChild(mappedBy = "parent"saved) @Transient ; // <-- ORM should NOT to persist 'saved' privateis Childmanaged child; }(proxied) 

I just got this error where two entities referenced each other via a @OneToOne mapping.

Using the @transient instructs the ORM not to persist that property.

NOTE that in the below example the child is the one with the foreign key to the parent.

public class Child {  @OneToOne()  private Parent parent;  // <-- ORM should persist as usual } public class Parent {  @OneToOne(mappedBy = "parent") @Transient  // <-- ORM should NOT to persist  private Child child; } 

I just got this error because I was setting an un-managed, un-proxied bean.

I should have been linking a proxied entity instance.

See the below explanation:

Child saved = childRepository.save(child);  // INCORRECT parent.setChild(child); // <-- 'child' is NOT managed (not proxied) // CORRECT parent.setChild(saved); // <-- 'saved' is managed (proxied) 
Post Deleted by Stephen Paul
deleted 4 characters in body
Source Link
Stephen Paul
  • 39.4k
  • 18
  • 99
  • 76
Loading
Source Link
Stephen Paul
  • 39.4k
  • 18
  • 99
  • 76
Loading