-->
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.  [ 3 posts ] 
Author Message
 Post subject: Range - composite Primary Key
PostPosted: Wed Nov 05, 2008 5:58 am 
Newbie

Joined: Thu Nov 15, 2007 6:07 am
Posts: 2
Location: Madrid, Spain
Hi to all

I have to migrate a project to Hibernate 3. This project has a very particular legacy table. This table stores ranges. As you know, a range is represented as two numeric values, so a number X belongs to a range [A-B] if A <=X and X <= B.
The primary key of this table is, therefore, the values [A, B] of the range (two fields): the minimum range field and the maximum range field.

My problem begins when I want to check if a certain number belongs to a range. I really don't know how to make this in Hibernate. In SQL I make the following sentence:

SELECT * FROM RANGE_TABLE
WHERE MINIMUM_RANGE_FIELD <= <value>
AND MAXIMUM_RANGE_FIELD >= <value>
AND.....

I don't want to make a HQL query, because I want to use the second-level hibernate caching (the range table is very often used).

Is this possible???.

Lot of thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2008 6:05 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
The second-level cache can be used to cache the result of queries (Query.setCacheable(true)), so if you don't have many different <value> values this could work. The query cache only caches the primary keys of the entities. If you want to cache the full Range objects you need to configure that as well.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2008 6:34 am 
Newbie

Joined: Thu Nov 15, 2007 6:07 am
Posts: 2
Location: Madrid, Spain
nordborg wrote:
The second-level cache can be used to cache the result of queries (Query.setCacheable(true)), so if you don't have many different <value> values this could work. The query cache only caches the primary keys of the entities. If you want to cache the full Range objects you need to configure that as well.


This table stores information about credit-card ranges. So there are a lot of possible <value> values.
I think caching the full Range objects is very hard for the performance, because this table has a considerable number of rows. So I'll try using Query.setCacheable(true) and check the performance.


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