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!
|