-->
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.  [ 7 posts ] 
Author Message
 Post subject: subclass and it's property
PostPosted: Sat Mar 05, 2005 10:52 am 
Beginner
Beginner

Joined: Tue Nov 09, 2004 6:26 am
Posts: 32
Hello.
This is a fragment of my mapping documents:

Code:
<class name="SubjectAddress" table="SUBJECT_ADDRESS"
     discriminator-value="0">
     <id name="id" column="SUBJECT_ADDRESS_ID" type="integer">
         <generator class="native"/>
     </id>
     <discriminator column="ADDRESS_TYPE" type="integer"/>
     <property name="subjectId" column="SUBJECT_ID" type="integer"                         
         not-null="true" />
     <property name="addressId" column="ADDRESS_ID" type="integer"             
         not-null="true" />
      <subclass
         name="com.rn.mapping.SubjectAddressPostal"
         discriminator-value="2"/>
</class>

<class name="com.rn.mapping.Person" table="PERSON" lazy="true">
     ...
     <one-to-one name="subjectPostalAddress"
    class="com.rn.mapping.SubjectAddressPostal"
    property-ref="subjectId"/>   
</class>



I get the folloswing error:
property-ref not found: subjectId in class: com.rn.mapping.SubjectAddressPostal.
Shouldn't this property be visible?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 05, 2005 12:16 pm 
Beginner
Beginner

Joined: Tue Nov 09, 2004 6:26 am
Posts: 32
The ideea is that I'm trying to make a query that contains
...
left join person.subjectPostalAddress subjpa
and to generate the following SQL
...
left outer join SUBJECT_ADDRESS subjectaddr on
person.SUBJECT_ID=subjectaddr.SUBJECT_ID and
subjectaddr.ADDRESS_TYPE=3

Do you think it's possible?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 05, 2005 1:50 pm 
Beginner
Beginner

Joined: Tue Nov 09, 2004 6:26 am
Posts: 32
Ok! I found something. The attribute polymorphism="explicit" for the class mapping element.
But my query still doesn't work.
I t only works when I simply try to get all SubjectAddressPostal. But it doesn't work when I use person.subjectPostalAddress...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 05, 2005 2:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
use <one-to-one class="SubjectAddress" property-ref="subjectId"/>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 05, 2005 2:56 pm 
Beginner
Beginner

Joined: Tue Nov 09, 2004 6:26 am
Posts: 32
gavin wrote:
use <one-to-one class="SubjectAddress" property-ref="subjectId"/>


If I use SubjectAddress for the relation, how will I obtain this?
Code:
left outer join SUBJECT_ADDRESS subjectaddr on
person.SUBJECT_ID=subjectaddr.SUBJECT_ID and
[b]subjectaddr.ADDRESS_TYPE=3[/b]

The last part is very important.

Why can't I see from the mapping the properties of SubjectAddressPostal?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 06, 2005 6:07 am 
Beginner
Beginner

Joined: Tue Nov 09, 2004 6:26 am
Posts: 32
Hello again

Personally when I post something it is also important for me to know if what I propose it's imposible to be done, or I need to study more.
I've put a lot of stupid question on thos forum, but after each of them I've returned to "Hibernate in Action" :)

So, pleas tell me at least if it si possible to generate that kind of outer join (with a subclass). I don't see why this couldn't be possible, but I don't seem to be able to "see" subjectId property of the subclass.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 06, 2005 9:17 pm 
Beginner
Beginner

Joined: Tue Nov 09, 2004 6:26 am
Posts: 32
in Hibernate 3 an association with a subclass is possible?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

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.