-->
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.  [ 2 posts ] 
Author Message
 Post subject: Where clause on secondary table
PostPosted: Wed May 18, 2011 7:53 pm 
Newbie

Joined: Wed May 18, 2011 7:46 pm
Posts: 1
I have an Entity created with a main table and 2 associated tables. I joined the primary-secondary tables using the hibernate annotations. Here is the snippet of the code.

@Entity @Table(name = "Table1") @org.hibernate.annotations.Entity(dynamicUpdate=true)
@org.hibernate.annotations.Tables ( { @org.hibernate.annotations.Table(appliesTo = "Table2", optional = false ), @org.hibernate.annotations.Table(appliesTo = "Table3", optional = false ) })
//@org.hibernate.annotations.Table(appliesTo = "Table2", optional = false )
@PrimaryKeyJoinColumn(name="t1_column1")
@SecondaryTables({
@SecondaryTable(name = "Table2", pkJoinColumns = {@PrimaryKeyJoinColumn(name = "t2_col1", referencedColumnName = "t1_col1")}),
@SecondaryTable(name = "Table3", pkJoinColumns = {@PrimaryKeyJoinColumn(name = "t3_col1", referencedColumnName = "t1_col1")})
})

This works fine. I want to specify a Where annotation that will be applied to the secondary table 'Table2'. By default the hibernate annotation "@Where" gets applied to only the target table which here is 'Table1'. As a result, I get an SQL error that the column included in the where clause is not found in 'Table1'.

Is there any special directive that I need to add to the @Where to make hibernate add the SQL where clause on the secondary table Table2?


Top
 Profile  
 
 Post subject: Re: Where clause on secondary table
PostPosted: Thu Oct 20, 2011 6:25 am 
Newbie

Joined: Thu Oct 20, 2011 6:07 am
Posts: 2
Hey I am facing the same problem. Did you resolve it ?


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

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.