-->
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.  [ 4 posts ] 
Author Message
 Post subject: Join two tables in one entity
PostPosted: Fri May 11, 2007 9:59 pm 
Newbie

Joined: Fri May 11, 2007 9:52 pm
Posts: 4
Hello,

I got the following question.

I have a table A where I got an ID column and some more.
In another table B I got a FK column to A.

I can define relationships in hibernate as I want but I got stuck as I want to use filters.
I want to select objects from A but the filter criteria is in table B.
As it seems, the filter can only be defined for columns in an entity and can't follow a relationship.

So is it possible to define an entity AB where I got the columns from A
and some columns from B?

in SQL I would do it with a query on A and an inner join on B.


thanx
Vulpo


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 3:38 am 
Beginner
Beginner

Joined: Mon Nov 06, 2006 2:40 am
Posts: 29
Location: New Delhi, India
try using formula queries?????


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 4:28 am 
Newbie

Joined: Fri May 11, 2007 9:52 pm
Posts: 4
Thanx for you help.

Well, formulas are used to compute something, I thought.

I thought more of this expression:

Code:
@Entity
@Table(name="table_a")

...

    @Column(name = "wastebasket", table="table_b", insertable = false, updatable = false)
    Character getBasket() {...}




If I do this that way, hibernate tells me, that the secondary table "table_b" couldn't be found. This is NOT during runtime - it's during the initialization of hibernate.
I don't know how to tell hibernate how to join table_a and table_b.

Any ideas how to do this?

Thanx
Matthias


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 17, 2007 10:03 am 
Newbie

Joined: Thu Nov 16, 2006 9:24 pm
Posts: 4
The following is missing, aleast at the code that you posted.

Code:
@SecondaryTables( { @SecondaryTable(name ="tabname")})


This works for me.

cheers
Projyal


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.