-->
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: Mapping entities to views?
PostPosted: Tue Sep 23, 2008 1:50 pm 
Newbie

Joined: Tue Sep 23, 2008 1:39 pm
Posts: 8
Hi, i have no much experience with Hibernate. I'm working on a booking system. I have a table with reservations and another one containing the reservations operations, so if somebody cancel a reservation there will be a new row in the reservation_operations table with an action 'cancel' and the reservation_id (which is a foreign key -> reservations table).

I guess it is clear. What i want is not to keep a reservation_status field in the reservations table but to calculate it dynamically in a view depending on the reservation_operations rows. I already have that view working.

I want to know if i should map my Reservation class to a view containing the reservation fields plus the status field or if i should keep the status as a separated entity class mapped to the reservation class status field. I don't know which is the best practice nor what is possible.

Any help will be welcome.
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 23, 2008 6:22 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
There is no reason not to use all the view's fields, including the calculated one.
Since nothing on the view is updateable, I doubt Hibernate will care how the calculated field came into existence. For Hibernate, they are just fields.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 23, 2008 6:57 pm 
Newbie

Joined: Tue Sep 23, 2008 1:39 pm
Posts: 8
Hi Gonzalo.
Thanks for your reply, i understand what you say, but my doubt comes due the need of having all the fields into the same class. I need to have all the updatable fields from reservations plus the read-only status field, ll them in the same class Reservation.

How can i do this? Or
How should i do this?

I have the Reservation class mapped to the reservations table, and now i have a view with the reservation_id and the reservation_status.

Maybe adding a new ReservationStatus class mapped to the view and adding a ReservationStatus member to my Reservation class? But the view has not id, only the reservation_id

Have any idea?


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.