-->
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.  [ 6 posts ] 
Author Message
 Post subject: get list of unmapped objects thru hibernate
PostPosted: Sat Nov 19, 2005 8:00 pm 
Newbie

Joined: Fri Nov 11, 2005 12:34 pm
Posts: 18
Hi,

I want a list of unmapped (in Hibernate) SummaryBusinessObjects.
Yet I'd like hibernate to map the result set to list of my objects.
(so something like
List myList = session.createSQLQuery(mySql).addMYOBJECT("currAd", SummaryBusinessObjects.class).list();

I've been reading a lot of documentation, and anything I find requires Entities.

Is there a way to do this that I haven't found on my own?

The only idea I have is to write a view for my query in db, and map my SummaryBusinessObjects to that view, and
then use it. But as I will never save, update or delete that object, I am wondering if something will tell hibernate not to treat this as a persistent object? (maybe class.mutable="false").

Any hints would be really appreciated and awarded :).

--MB


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 19, 2005 9:35 pm 
Newbie

Joined: Fri Nov 11, 2005 12:34 pm
Posts: 18
BTW this guy asked the same question as I did, and got no answer: http://forum.hibernate.org/viewtopic.php?t=939083

I am sensing that the question is dumn, but if anyone can tell me why that could help :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 19, 2005 10:13 pm 
Newbie

Joined: Fri Nov 11, 2005 12:34 pm
Posts: 18
I found about session.setFlushMode(FlushMode flushMode)

"Set the flush mode. The flush mode determines at which points Hibernate automatically flushes the session. For a readonly session, it is reasonable to set the flush mode to FlushMode.NEVER at the start of the session (in order to achieve some extra performance)."


Seems reasonable.


Do you think I'm on the right track?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 20, 2005 11:53 am 
Regular
Regular

Joined: Thu Oct 27, 2005 8:06 am
Posts: 55
Location: München, Germany
I'm not sure whether I understand the point of your question. Is it about using unmapped data, or about read-only transactions?

The unmapped topic might be resolved for you by reading p 271 of Hibernate in Action, titled "Using dynamic instantiation". A short example of this is contained in the Hibernate reference manual on p 144.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 20, 2005 1:04 pm 
Newbie

Joined: Fri Nov 11, 2005 12:34 pm
Posts: 18
First, thanks for the attention and time,

Quote:
I'm not sure whether I understand the point of your question. Is it about using unmapped data, or about read-only transactions?


It is about both :)

I would like to be able to get unmapped data. But if I cannot do it (or don't know how to) I would like to make the thing mapped, but somehow mark it readonly, as to improve performance.

Thanks for pointing out those pages. Yes, I have seen them.

This is query from Hib In Action:
Quote:
select new ItemRow( item.id, item.description, bid.amount )
from Item item join item.bids bid
where bid.amount > 100


For that to work I need Item mapped. As I have 7 joined tables in my query I would not otherwise map, I think this is not the best solution for my problem.
Plus I think you can only do joins on how the table's are mapped which could be a limitation, but probobly will not.

For now I created a view, mapped the view to a BusinessSummaryObject class, using mutable="false" and session.setFlushMode(FlushMode.NEVER); This seems ugly.

Regards,
MB


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 20, 2005 6:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
native sql queries does not support returning unmapped objects - only entities and scalar values (at the moment).

_________________
Max
Don't forget to rate


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