Hi all,
I need to map a Java class called Friend which is made up entirely of properties that come from other tables/mapped classes.
eg
Code:
class Friend {
private String userUuid;
private boolean confirmed;
private String statusMessage;
private Date statusDate;
private byte[] photo;
...
}
where userUuid and confirmed comes from ProfileFriend (PROFILE_FRIEND_T), the status fields come from ProfileStatus (PROFILE_STATUS_T) and the photo comes from a field in PERSON_T. The userUuid is the joining property across all tables, except in the last table it's called something else (agentUuid).
I am not sure how to set out my hbm.xml so that Friend is mapped properly. There is no table that Friend maps directly to.
The reason for this is because of a particular SQL query, I need it to return a list of Friend objects rather than a list of Object[] arrays.
My sql query is this:
Code:
<sql-query name="getFriendsForUser">
<return alias="friend" class="Friend"/>
<![CDATA[
select PROFILE_FRIENDS_T.FRIEND_UUID as {friend.userUuid}, PROFILE_FRIENDS_T.CONFIRMED as {friend.confirmed}, PROFILE_STATUS_T.MESSAGE as {friend.statusMessage}, PROFILE_STATUS_T.DATE_ADDED as {friend.statusDate}, PERSON_T.JPEG_PHOTO as {friend.photo} from PROFILE_FRIENDS_T left join PROFILE_STATUS_T on PROFILE_FRIENDS_T.FRIEND_UUID=PROFILE_STATUS_T.USER_UUID left join PERSON_T on PROFILE_FRIENDS_T.FRIEND_UUID=PERSON_T.AGENT_UUID where PROFILE_FRIENDS_T.USER_UUID = :userUuid
union
.... some more sql.
]]>
</sql-query>
Can someone please help me? Thanks.
Code: