-->
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 relation with multiple join colums
PostPosted: Wed Nov 13, 2013 3:26 am 
Newbie

Joined: Wed Nov 13, 2013 3:22 am
Posts: 1
I have the following case:

table A {id_a, column1, column2, column3_A}
table B {id_b, id_a, column1, column2, column3_B}
table C {id_c, id_b, column1, column2, column3_C}
id_a, id_b and id_c are primary keys and there is a one to many relation between A and B and one to many relation between B and C. These tables are Oracle partitioned tables where the partition key in all tables is (column1,column2).

I would like to use Hibernate for DB operations but for performance reasons all underlying sql select queries should contain as additional condition the partition key, ex:

// when data should be retrieved from B table Hibernate should generate
select * from B b
inner join C c on b.column1=c.column1 and b.column2=c.column2 and b.id_b=c.id_b
where b.id_a=? and b.column1=? and b.column2=?
Please notice the additional join columns between the 2 tables.

I don't have too much experience with Hibernate and I wasn't able to resolve this situation so far. I tried to use @JoinColumns to add the additional 2 columns (column1 and column2) in the join clause but in this case I had problems during insert because I had to mark these columns as insertable=false, so they were missing from the insert query (since they are not nullable this is not possible).

Can somebody give me a hint?


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.