I have in Class a field Map<Object, String> type. How can I save Object's from Map when parent Class object save?
I understand whats the problem, but cant solve it. I cant place annotation @***ToMany to indicate cascade = ALL, talk targets the type 'java.lang.String' which is not an '@Entity' type
, I think thats apply annotation on map.value.
Tell me the right way, please.
Thanks a lot.
Code:
@Entity
@Table
public class Profile {
....
@ElementCollection
@MapKeyJoinColumn(name="addressId", referencedColumnName = "addressId")
@Column(name = "description")
@CollectionTable(name = "ProfileAddress",
joinColumns = {@JoinColumn(name = "profileId", referencedColumnName = "profileId")})
private Map<Address, String> addresses; //String it's description for address - "home", "work" etc. I want separate table with parentObjectId, addressId, description. And need that create/delete/update Address object's with Parent object together.
Address is Entity of course.
Error:
object references an unsaved transient instance - save the transient instance before flushing