-->
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: Can I put runtime values into where or formula attributes?
PostPosted: Thu Nov 24, 2005 5:23 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I have a normal one:many relationship (IPRouter to configuration) in the database suitable for mapping with the <map> element. However I know that I will only ever retrieve one value from this map: the map-key will be a date, which will always be provided. My current approach is to not provide the getMap() method in the router's interface; I'm storing the relevant date in the router object, and a getConfiguration() method which returns getMap().get(date).

This is working, but it does mean that every configuration is being loaded when I load the router. When I want to compare two configurations, I load the same router twice, once for each date, and compare the two getConfiguration() returns. Effective but highly inefficient.

Is there a way to specify a "dynamic" one-to-one mapping? Something like `where="date=:Date"' in the map? Or maybe a <one-to-one> with a formula that takes a parameter from a query? Some of the routers I'm looking at have hundreds of configurations, and the memory overhead is great enough that I'm considering removing the hibernate map entirely, and implementing this via factory methods.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 27, 2005 11:41 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Would filters be an option you can try? I read from the documentation that you can enable and disable filters too?

Also could you not use a HQL with the "where" condition to get your "Router" objects instead.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 27, 2005 11:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You can use a filter. But that might be overkill in this case.

A simpler approach is to use lazy="extra" in Hibernate 3.1.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 12:05 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I'll check out the 3.1 docs to see if that does what I need. I notice that they're not on the documentation page on www.hibernate.org. I can't get the full download until next month (silly international traffic limitations) so I can't say for sure that lazy="extra" is what I want.

I'll read up on filters to pass the time until then :)


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.