Reputation: 11
I have a similar requirement as that of problem statement defined in I want to map a Map<Long, List<POJO>> through JPA
I am using eclipselink, I also had to create a separate class ItemAttributes , but in this class atleast I have to use primarykey for table ITEM_ATTRIBUTE. However the configuration is able to fetch the results in map, but while creating new record the eclipselink tries to consider the ItemAttributes as entity & hence ends up in inserting value for primarykey(which is null) in table ITEM_ATTRIBUTE which I don't want , I want only the list of - List attributes to be inserted. Surprisingly I cannot make the primary key as read only declared in ItemAttributes class.
Any idea how to avoid this? Further I cannot make the descriptor class ItemAttributes as read only as it will skip the creation part of entire table ITEM_ATTRIBUTE I am using eclipselink workbench for configuration.
Upvotes: 0
Views: 139
Reputation: 18379
You need to create an Entity class to represent the relationship as in the answer to the other post.
What is your exact model/data model.
Your intermediate class will need an Id, you can use an @GeneratedValue if you have no logical one.
Upvotes: 1