-->
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: Parent/child relationships with time-dependent data
PostPosted: Thu Jun 30, 2005 11:00 am 
Newbie

Joined: Thu Jun 30, 2005 10:49 am
Posts: 2
Hi

I was wondering if anyone could help me with a problem I am having mapping relationships in my legacy database. All of the data in the database is time-dependent and has date/time columns like valid_from and valid_to. The primary key is comprised of a single identifier column and these date fields so if I want to get the value for one for the current date I would need to query it like this:

select * from table_name where id=:id and valid_from <= current_time() and valid_to > current_time()

If I am accessing a row directly this is fine and I can use a predefined query to get the result for my id value.

However, I need to set up a parent/child relationship which includes this kind of lookup. Does anyone know how I can define a property mapping where I can specify that a child attribute (for example my valid_from column above) is less than or equal to one of the parent attributes or at least less than or equal to the current_time() value? Is my best bet to use a <formula> element and put the whole query in there or could I map this so that hibernate can still return the parent and child with a single query using an outer join?

Any thoughts or suggestions would be much appreciated.

Thanks

ps. I have tried various mappings to get this right and nothing has worked so far so I don't really have any example stuff to post at the moment but I can provice more details if this would be helpful.


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.