-->
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: Complicated Joins
PostPosted: Thu Jul 20, 2006 5:30 am 
Newbie

Joined: Thu Jul 20, 2006 4:18 am
Posts: 2
Hi

I am fairly new to using the Hibernate and Spring frameworks and have a question on how to map a complicated join in my database.

I am building a telephone number database and have two tables I wish to join using the hbm.xml config files. The two tables are Ranges and Numbers for which one range can have many numbers.

Ranges are stored based on consectutive numbers being within the same status (e.g. allocated to customer). Now because the ranges change in size all the time based on users reserving numbers and sub ranges within larger ranges, it is not feasible to have a regular primary/foreign key relationship as it would mean huge updates in the numbers table everytime a range was fragmented into smaller ranges.

However I could build SQL joins based on the SQL query below.

Code:
SELECT * FROM num.numbers n CROSS JOIN num.ranges AS r  WHERE n.prefix = r.prefix AND n.static_bit = r.static_bit AND CAST(n.variable_bit as UNSIGNED) BETWEEN CAST(r.start_variable_bit as UNSIGNED) AND  CAST(r.end_variable_bit as UNSIGNED)


Does anyone know of any way of replicating this SQL into a .hbm.xml file?

Thanks

Stuart


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.