-->
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.  [ 2 posts ] 
Author Message
 Post subject: How do we map view in hibernate mapping file?
PostPosted: Wed Mar 28, 2007 7:37 am 
Newbie

Joined: Wed Mar 28, 2007 7:28 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

3.1.3:

Mapping documents:
[b] How do we map view query in hibernate mapping file

This is my view.
create view con_metrix as
select trans_log.CONTRACT_NAME contractName,
avg(trans_log.PROVIDER_WS_TOTAL_TIME) averageTime ,
MAX(trans_log.PROVIDER_WS_TOTAL_TIME) maxRespTime,
MIN(trans_log.PROVIDER_WS_TOTAL_TIME) minRespTime,
COUNT(trans_log.STATUS) status from CON_TRANSACTION_LOG trans_log
GROUP by
trans_log.CONTRACT_NAME, trans_log.STATUS;
How can i map this to mapping xml

Thanks
Shanmugam.VE


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 12:25 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
You could map it like any other entity. However the catch is that data in a view is really not a "persistent" entity.

There are some approaches to solve your problem:
1. Declare the query for the viewas HQL and use it in your application. However if the view is being used for other JOINs this might not work out.

2. Declare the view as a Persistent Entity. The downside is that you are forced to define a "id" element for the <class> even though you can never insert or update to the view. You can prevent INSERT and UPDATE of other properties using the "insert=false update=false" attributed of <property> but <id> does'nt support that. There are definitely loop holes to making this a persistent entity.

3. Do no make this a persistent entity. You can have standalone class representing the results and use can ask Hibernate to type case the result into that class using the "select new Metrics(.....) from.." syntax of HQL. This way the Metrics Java class is not required to be Persistent and will not be managed by Hibernate.

_________________
--------------
Don't forget to Rate the post


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