Entity picker - Error with action "entity_openComposition"

Hi,
I am trying to use component “Entity picker” with action “entity_openComposition”.
My entity(Goal) has association with another entity(Result), where is One to One cardinality and “Goal” is owning side.

I am using in Edit screen Entity picker with action entity_openComposition. But when I press button on screen, when Result entity is empty, instead of creating new and show editor of that entity, I got error:

IllegalStateException: Editor of class {rootName}.motivation.mpr.entity.MprResult cannot be open with mode EDIT, entity is not set

In XML, Entity picker have “Property” attribute and action just “ID” and “Type”.

Thank you

Hi Pavel,
Could you provide a test project?

Hi,
sorry for delay, I am sending test project, where you can see an OpenComposition Error. Try create a “Position” and use action “openComposition” to create and associate “Phone” to position.

JMIX - openCompositionTestProject.zip (331.3 KB)

Thank you

Hi Pavel,

I opened your project and saw that the relationship is not marked as composition:

@JoinColumn(name = "PHONE_ID")
@OneToOne(fetch = FetchType.LAZY)
private Phone phone;

Select “COMPOSITION” in “Attribute type” field, so the definition will be like this:

@Composition
@JoinColumn(name = "PHONE_ID")
@OneToOne(fetch = FetchType.LAZY)
private Phone phone;

Please re-test your situation and let me know if it still doesn’t work for you.

Ahh ok, sorry :slight_smile: I am always using Association, so i forgot there is more possible relations settings :). Thank you, now its working perfectly.

Just can you assure me, there is no big difference in Association One to Many and Composition One to Many, am I right? Or is there any really big difference, which couble cause some problems, when I change it for some attributes?

Pavel

Actually @Composition affects only the UI and generic REST behavior, so it shouldn’t cause any problems on the database or business logic level.