-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate and View
PostPosted: Mon Dec 15, 2003 9:02 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:44 am
Posts: 58
Location: Paris, France
Dear all,
I would like to know if it is possible to use view with hibernate.
Actually I have the following view :
Code:
CREATE VIEW ADHERENT_COUNT AS
select TO_CHAR(count(*),'00000') AS COUNT FROM ADHERENT WHERE TO_CHAR(DATE_CREATION, 'YYYY/MM/DD') = TO_CHAR(SYSDATE, 'YYYY/MM/DD');


I would like to know how can I fetch this count ?
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 9:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Just map a class to the view as you would map a class to a table


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 9:17 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:44 am
Posts: 58
Location: Paris, France
Ok but how can I manage the since I haven't any ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 9:17 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:44 am
Posts: 58
Location: Paris, France
sorry ..
gbonnard wrote:
Ok but how can I manage the KEY since I haven't any ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 9:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Probably you could use generator=assigned, which might stop hibernate from trying to get the key from the database ... don't know if this works


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 9:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Mapping a Key when no primary key in the table is a FAQ question.
Select a subset (or not) of the fields that can act as a key and map it as one. Alternatively, map all the fields as a single composite key so the object has no properties other than the key. If this cannot work as a key then your not in the relational world and you will need to rework your View.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 2:02 pm 
Regular
Regular

Joined: Thu Nov 20, 2003 10:44 am
Posts: 58
Location: Paris, France
Ok thanks I use my column as key even if it isn't !


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