Please Observe below scenario
Code:
Class Responsible{
.....
@MapKey(name = "addressType")
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "responsible")
protected Map<String, ContactAddress> addresses = new HashMap<String, ContactAddress>();
.....
}
Code:
Class ContactAddress {
.....
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "typeId", unique = true)
protected AddressType addressType = new AddressType();
.....
}
Code:
Class AddressType {
.....
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "typeId", unique = true, nullable = false)
protected Long typeId;
.....
}
When Responsible record fetched then the addresses(MAP) is loading with
AddressType as key and ContactAddress as values in MAP. But I need
AddressType.typeId as key in that MAP.
How can I get that typeId as key in addresses MAP?
Thanks
Ram