@Id fields with name different than 'id'

53 Views Asked by At

In admin module I created new entity with list of countries

   @OneToMany(targetEntity = CustomISOCountryImpl.class, mappedBy = "someEntity")
   @AdminPresentationCollection(friendlyName = "someEntityImpl_Countries", addType = AddMethodType.LOOKUP)
   private List<CustomISOCountryImpl> countries;

CustomISOCountryImpl inherits from ISOCountryImpl. I set the AddMethodType as LOOKUP. Now, when I try to add only one country from a list all of them are being added. It is only temporary effect, as they don't get persisted (they vanish after page refresh). Moreover, when I try to delete one of them I get an error:

Could not find the primary key property (alpha2) in the passed entity with type: xxx.xxx.xxx.CustomISOCountryImpl

After a while of debugging I found out that the problem is that broadleaf expects field with anootation @Id and field 'id', but the @Id of ISOCountryImpl is of a String type and is named 'alpha2'.

Any idea how to work this around ?

0

There are 0 best solutions below