-->
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: Single object based on view, but used with table, too
PostPosted: Wed Dec 06, 2006 12:31 pm 
Newbie

Joined: Wed Dec 06, 2006 11:36 am
Posts: 8
Greetings.

I have an object that was based on a view, so it's got fields that map to multiple tables in addition to derived/calculated columns.

Most of the time, the only things I need in this object are the columns from the primary table, so a straight old mapping file has worked well for querying and updates.

I have a need in a number of places, though, to populate the object with the results of the view which, as i said, contains lots of other columns. these objects are read-only.

problem is, when I use the view in a named query, the only fields that are populated in the object are the ones from the normal mapping (obviously, I guess).

So what I need is this:

A) Normal old mapping: should just use the regular class mapping

B) with the named query using the view, i want the "full" object, which would be populated by the columns in the view.

here's my mapping document:

<hibernate-mapping>

<class name="com.argus.doh.beans.RequestStatusBean" table="Requests" >

<id name="requestID">

<column name="RequestID" />

<generator class="native" />

</id>



<property name="statusID"/>

<property name="createTS"/>

<property name="completeTS"/>

<property name="systemID" update="false"/>

<property name="requestTypeID" update="false"/>

<property name="rushRequest" insert="false" update="false"/>

<property name="successAction" update="false"/>

<property name="failureAction" update="false"/>

<property name="jobOption" insert="false" update="false"/>

</class>


<!-- i want this query to return all fields in the view and populate the RequestStatusBean object with those fields. there's a direct map between column names and object properties -->



<sql-query name="VRequestByStatusGrouped">

<return class="com.argus.doh.beans.RequestStatusBean"/>


SELECT *

FROM V_RequestStatuses

WHERE StatusID=?

GROUP BY RequestID, SystemID, RequestTypeID, RushRequest, StatusID, SuccessAction, FailureAction, CreateTS, CompleteTS, JobOption,

RequestTypeName, SystemName, ErrorRecipients, StatusName, PriorityName, PriorityID,

TotalFileCount, PendingFileCount, PausedFileCount, RunningFileCount, CompletedFileCount, FailedFileCount, CancelledFileCount

</sql-query>



</hibernate-mapping>


Any help is MOST appreciated! pointers to the appropriate spot in the documentation, etc...Thanks!


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.