Hi all,
I'd like to know if a special mapping is possible.
In the database :
1 A entity - n B entity.
1 B entity - 1 A entity.
A (aid, aname) and B (bid, bcode, #aid)
Mapping :
I succeed in get in A entity a bcode set (of String) without using the B entity. A side :
Code:
@CollectionOfElements
@JoinTable(name = "b", joinColumns = @JoinColumn(name = "aid"))
@Column(name = "bcode", nullable = false)
public Set<String> getCodes() {
return codes;
}
I get a set of String and not a set of B entity :)
Now, I'd like to be able to get the aname field of the A entity directly in the B entity without using the A entity :
(in the B entity)
Code:
public String getAName() ...
It seems impossible with ManyToOne annotation :(.
The only thing I succeeded in is :
Code:
@ManyToOne(fetch = FetchType.LAZY, targetEntity = AImpl.class)
@JoinColumn(name = "aid")
public A getA() ...
Thanks