-->
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: hibernate mapping dilemmas
PostPosted: Wed Feb 23, 2005 11:31 am 
Newbie

Joined: Tue Feb 22, 2005 5:23 pm
Posts: 3
Hi

This is description of my problem:

I have two tables: THREAD (id, name) and THREAD_STAMP (thread_id,user_id)

First table describes the forum thread , the second describes if the thread was read by particular user.

Now I want to get the list of threads but with info if the thread was read by particular user.

From the sql level it should enough to generate query like this:

select t.*,ts.* from THREAD t left outer join THREAD_STAMP ts ON t.id=ts.thread_id WHERE ts.user_id=givenvalue or ts.user_id is NULL;

So it could be done with only one select. It can be also well interpreted, if the user_id is not null in particular row it means that that thread was read by the user.

If I will follow the plain jdbc approach I can parse the jdbc result set and fill the list of container objects of class ThreadRow that has fields threadId, threadName and userId. I need that data only for reports so read only purpose.

But what if I would like to use Hibernate for such structures. Is it possible to automatically copy the data from database result set to the list of report objects ?. I have tried with createSqlQuery(...) but with that I need the class ThreadRow to be mapped which is impossible because it takes data from several tables. Also tried with dynamic initialization (constructor for ThreadRow with lot of params) but have no idea how to create mapping that generates above sql. The reason of all above is because of performance, it should work extremely fast.

Is there any way it could be done with Hibernate with also one database sql query.???

Bartek


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.