-->
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: Problem with composite key and a computed property
PostPosted: Thu May 08, 2008 1:09 pm 
Newbie

Joined: Thu May 08, 2008 1:01 pm
Posts: 1
Hello All,

I've tried every way that I can think to get this to work, and I've searched the forums and the 'Net and am still stuck.

When I try to start my app, I get a NullPointerException several layers down when my session factory is trying to be created. That's not the real issue I don't think, but it's buried down there. I've turned on all the logging and don't get any more information.

Here's my mapping:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
<class name="com.blockbuster.online.domain.model.community.entity.FriendRelationship"
table="USER_FRIEND"
where="FRIEND_STATUS != 'INACTIVE'"
>
<composite-id name="id"
class="com.blockbuster.online.domain.model.community.entity.FriendRelationship$FriendRelationshipId"
access="field"
>
<key-many-to-one
name="user"
access="field"
column="WEB_USER_ID"
class="com.blockbuster.online.domain.model.acctmgmt.entity.User"
/>

<key-many-to-one
name="friend"
access="field"
column="FRIEND_USER_ID"
class="com.blockbuster.online.domain.model.acctmgmt.entity.User"
lazy="proxy"
/>

</composite-id>

<property
name="screenName"
type="java.lang.String"
insert="false"
update="false"
lazy="false"
not-null="false"
formula="( SELECT p.screen_name FROM user_profile p WHERE p.web_user_id = web_user_id ) "
access="field"
/>

<property
name="displayName"
type="java.lang.String"
column="FRIEND_DISPLAY_NAME"
access="field"
/>

<property
name="friendStatus"
type="java.lang.String"
column="FRIEND_STATUS"
access="field"
/>

<component
name="changeAudit"
class="com.blockbuster.online.domain.model.common.component.ChangeAudit"
>
<property
name="createdBy"
type="java.lang.String"
column="CREATED_BY"
/>

<property
name="createdDate"
type="java.util.Date"
column="CREATED_DATE"
/>

<property
name="updatedBy"
type="java.lang.String"
column="UPDATED_BY"
/>

<property
name="updatedDate"
type="java.util.Date"
column="UPDATED_DATE"
/>
</component>

</class>
</hibernate-mapping>

The issue is the 'screenName' property. The table USER_FRIEND is the table for this mapping. There is another table called USER_PROFILE, and I want to get the SCREEN_NAME field from it.

Both of the tables contain a WEB_USER_ID column. Each USER_FRIEND record, might or might not have a corresponding record in USER_PROFILE (there is no relationship or constraint between them).

I think the problem is that the mapping uses a composite key (for what reason, I have no idea, this is inherited code). The screenName property's formula needs to match on WEB_USER_ID, but it's buried in the composite key. Any ideas on how I can get this to work?

Thank you very much,

Rex


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.