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: Hydrating One-To-One Objects Using Stored Procedure
PostPosted: Fri May 23, 2008 3:33 pm 
Newbie

Joined: Fri May 23, 2008 3:14 pm
Posts: 2
I am trying to use a stored procedure to hydrate an object graph. Stored Procedures are required by the business. (Please don't recommend I switch)

I have an object called "Comment" which contains:

Comment
--CommentID
----CommentText
----FromUser
------UserID
------UserName
------Profile (One-to-one)
--------ImageURL
----ToUser
------UserID
------UserName
------Profile (One-to-one)
--------ImageURL

I am trying to hydrate specific properties on the Comment, FromUser, FromUser.Profile, ToUser, ToUser.Profile objects. There are two problems I am running into:

1. How to I map ToUser.UserID to the column "ToUserID" in the dataset returned by the stored proc?
2. How can I hydrate the Comment.ToUser.Profile object? Every documentation I've read shows hydrating a class one level below the top level, but no deeper in the object graph.

Here's my sql query mapping file (which is not valid at this point):

<sql-query name="MSG_CommentSearch">
<return alias="Comments" class="Comment" >
<return-property name="CommentID" column="CommentID"/>
<return-property name="FromUser">
<return-column name="UserID"/>
<return-column name="UserName"/>
</return-property>
<return-property name="ToUser" >
<return-column name="UserID" />
<return-column name="UserName"/>
</return-property>
<return-property name="CommentText" column="CommentText" />
<return-property name="PostDate" column="PostDate"/>
</return>
exec dbo.MSG_CommentSearch :Status, :IsCount, :Page, :PageSize, :OrderBy
</sql-query>


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.