Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting a single field from another table using Hibernate 3 mapping

843859Jan 13 2008 — edited Nov 20 2014
I need to get a single field from another table that is joined to my table using a foreign key. I know I can get this by writing the SQL, and that I can get it by setting up a class that represents a very limited version of the other table. I know I could denormalize the data and put that field in my table. Is there a way using hibernate 3 mapping to get something like:

select t.*, o.data from my_table t
left join other_table o on o.pkey = t.fkey

into the class.

There is a many to one relationship between my_table and other_table. I don't want to get all of the other table, because it is quite wide and the query may return a lot of rows (the first table has about 200000 rows). And lazy fetching won't help, since I end up looking at all the rows I fetch.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 16 2008
Added on Jan 13 2008
15 comments
2,902 views