We have a persistence object A which has a property List(Object b).

When we remove one object b from the list with:

out.questionnaireConcept.QuestionnaireConceptParticpants.remove(in.participantToRemove);

and then try to persist this with:

ivy.persistence.***MuPersistence.merge(in.questionnaireConcept);

The participant which we tried to remove is still present in the database. I thought this could be set within the persistence definition in this window:

alt text

Do we have to remove the object b separately from the database or how can we achieve this?

asked 18.06.2015 at 14:11

Nikel%20Weis's gravatar image

Nikel Weis
(suspended)
accept rate: 57%


To have this feature working you need to set an additional property on the participant List field which is not accessible from the UI: orphanRemoval=true

You can set the property as follows: switch into the Java Perspective -> right click on the generated entity data class in src_dataClasses -> open with -> java editor. Find the line where the List<?> (participants) is declared. Add the orphanRemoval property.

  @javax.persistence.OneToMany(cascade={javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.REMOVE, javax.persistence.CascadeType.REFRESH}, fetch=javax.persistence.FetchType.EAGER, mappedBy="organisation", orphanRemoval=true)
  private java.util.List<ch.monokellabs.crm.db.OrganisationPhone> phones;

As soon as you're typing something in the Java Editor you have to press ok on the prompt that informs that you're editing a derrived resource. This means that whenever you edit the DataClass with the UI editor, you're changes will be overwritten. So for long term it could make more sense to copy the whole java class into your normal java source code and delete the DataClass.

Further informations to the orphanRemoval property can be found on stackoverflow: http://stackoverflow.com/questions/4593241/jpa-removing-item-from-list

link

answered 23.06.2015 at 11:44

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958
accept rate: 70%

edited 23.06.2015 at 11:49

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×32

Asked: 18.06.2015 at 14:11

Seen: 2,391 times

Last updated: 23.06.2015 at 11:49