Entity with multiple-fields key

Hi how can i handle the situation where i have an entity which must have as @Id multiple columns, i tried with @Embeddable but it fails when the key has reference to a entity , and i need from another Entity to create a m2o using that field (the one presents in the key)

Hi Federico

Sorry, when I jump in this thread. Attached you find a project where the following scenario is solved.

We have Collections where each Collection has different Codes.

Sample
Collection Stones, Code 1 = big, 2 = small
Collection Animals, Code 1 = male, 2 = female

The key lies in

  • CodeCompKey. I have no idea, how to generate this entity with the UI.
  • To enter codes, you have to select first a collection and for the CodesDetailView you need to initialise the CodeCompKey
	@Subscribe
	public void onInitEntity(final InitEntityEvent<Code> event) {
		CodeCompKey key = dataManager.create(CodeCompKey.class);
		key.setcCollection_id( event.getEntity().getcCollection_id().getCollection_id());
		key.setCode( event.getEntity().getId().getCode() );
		event.getEntity().setId( key );
	}

RelationDouble.zip (1.0 MB)

Hopefully this helps.

Regards
Felix