-->
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: @ManyToOne with "fake" column
PostPosted: Fri May 25, 2012 9:06 am 
Newbie

Joined: Fri May 25, 2012 8:52 am
Posts: 6
Hi,

Code:

MyChild.class
....
@ManyToOne
@JoinColumns({
    @JoinColumn(name="p_code",referencedColumnName="p_id",insertable=false,updatable=false),
    @JoinColumn(name="block_nr",referencedColumnName="block_nr",insertable=false,updatable=false)
    })           
    private MyEntity fparam;



My MyEntity has embeddable pk with two fields but my Child entity only has one of them (p_id). I would like to set up the relationship described above but I'd like to provide a value for block_nr and not the column.
At the end my query would look like this.

select * from myentity where p_id=:p_code and block_nr=1;


I just want to query the description belongs to the p_code nothing more.
I could achieve this via namedquery but usually I love to choose the harder way :).
Is it possible in this way or should I forget it ?
TIA

Regards, Sandor


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.