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: problem with join table
PostPosted: Tue Sep 04, 2007 4:49 am 
Newbie

Joined: Tue Jul 17, 2007 9:05 am
Posts: 9
Hi all,
I' have been using Hibernate for a couple of years and I always found what I needed inside of that excellent framework... except for the issue I'm currently facing...

Here is what I need :

On the database side, I have got 2 tables : tb_client and tb_client_def. Here is my database structure :

Code:
tb_client
  integer Id

tb_client_def
   integer client_id
   varchar first_name
   varchar last_name
   date start_date
   date end_date



As you can guess, I generally have several client definitions for one client. But I am mostly interested in the current one (for each client, there is only one client_def that matches tb_client_def.start_date < system.current_date < tb_client_def.end_date).


On the java side, I would like to have a POJO as follows :

Code:
public class Client {
  private int id;
  private String firstName;
  private String lastName;
  private Date startDate;
  private Date endDate;
}



In the Hibernate mapping, I tried to use a join-table, but I did not find a way to add my search criteria on a join table (tb_client_def.start_date < system.current_date < tb_client_def.end_date).


At the moment, the only workaround I found is to create a view in my database, that returns the current client according to my criteria. I would have prefered to use Hibernate instead of relying on the database.


Did someone ever do that with Hibernate ?


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.