-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Mapping : @ManyToOne of a specific entity field
PostPosted: Fri Aug 21, 2009 6:20 am 
Newbie

Joined: Fri Aug 21, 2009 6:05 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.