-->
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.  [ 4 posts ] 
Author Message
 Post subject: one-to-one mapping problem
PostPosted: Tue Feb 24, 2004 4:51 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 2:14 pm
Posts: 40
Location: Atlanta, GA, USA
I have the following class relationship...

Person
---- User extends Person
-------- Candidate extends User

... and Candidate has a CandidateProfile


Here is the mappins for this...

Code:
<class
        name="com.matrix.mss.bo.user.Person"
        table="User"
        dynamic-update="false"
        dynamic-insert="false"
        discriminator-value="P"
    >

        <id
            name="id"
            column="User_ID"
            type="int"
            unsaved-value="0"
        >
            <generator class="native">
            </generator>
        </id>

        <discriminator
            column="subclass"
            type="character"
        />

        ...       

             <subclass
                 name="com.matrix.mss.bo.user.User"
                 dynamic-update="false"
                 dynamic-insert="false"
                 discriminator-value="U"
             >

             ...
       
       
                  <subclass
                      name="com.matrix.mss.bo.user.candidate.Candidate"
                      dynamic-update="false"
                      dynamic-insert="false"
                      discriminator-value="C"
                   >

                       <one-to-one
                           name="candidateProfile"
                           class="com.matrix.mss.bo.user.candidate.CandidateProfile"
                           cascade="save-update"
                           outer-join="auto"
                           constrained="false"
                       />
      
                  </subclass>

            </subclass>

</class>

<class
        name="com.matrix.mss.bo.user.candidate.CandidateProfile"
        table="Candidate"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="Candidate_ID"
            type="int"
            unsaved-value="0"
        >
            <generator class="native">
            </generator>
        </id>

        ...

        <many-to-one
            name="candidate"
            class="com.matrix.mss.bo.user.candidate.Candidate"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="User_ID"
        />       
       
</class>


When I run the following code...

Code:
List list = session.find("from Candidate");
ListIterator iter = list.listIterator();

  while (iter.hasNext()) {
    Candidate candidate = (Candidate) iter.next();
    CandidateProfile candidateProfile = candidate.getCandidateProfile();

    ...


... the CandidateProfile is not returned. It is null. I get this meesage in my debug log...
object not resolved in any cache [com.matrix.mss.bo.user.candidate.CandidateProfile#44]
... what does that mean?

I think I just have something slightly messed up in my mappings because inserting is working fine. TIA for any help.

Here is my debug log...

2004-02-24 15:13:34,409 [main] DEBUG hibernate.impl.SessionImpl(531) -> opened session
2004-02-24 15:13:34,409 [main] DEBUG hibernate.transaction.JDBCTransaction(37) -> begin
2004-02-24 15:13:34,409 [main] DEBUG hibernate.transaction.JDBCTransaction(41) -> current autocommit status:false
2004-02-24 15:13:34,409 [main] DEBUG hibernate.impl.SessionImpl(1497) -> find: from Candidate
2004-02-24 15:13:34,409 [main] DEBUG hibernate.hql.QueryTranslator(147) -> compiling query
2004-02-24 15:13:34,424 [main] DEBUG hibernate.impl.SessionImpl(2210) -> flushing session
2004-02-24 15:13:34,424 [main] DEBUG hibernate.impl.SessionImpl(2403) -> Flushing entities and processing referenced collections
2004-02-24 15:13:34,424 [main] DEBUG hibernate.impl.SessionImpl(2746) -> Processing unreferenced collections
2004-02-24 15:13:34,424 [main] DEBUG hibernate.impl.SessionImpl(2760) -> Scheduling collection removes/(re)creates/updates
2004-02-24 15:13:34,424 [main] DEBUG hibernate.impl.SessionImpl(2234) -> Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
2004-02-24 15:13:34,424 [main] DEBUG hibernate.impl.SessionImpl(2239) -> Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2004-02-24 15:13:34,424 [main] DEBUG hibernate.impl.SessionImpl(1782) -> Dont need to execute flush
2004-02-24 15:13:34,424 [main] DEBUG hibernate.hql.QueryTranslator(199) -> HQL: from com.matrix.mss.bo.user.candidate.Candidate
2004-02-24 15:13:34,424 [main] DEBUG hibernate.hql.QueryTranslator(200) -> SQL: select candidate0_.User_ID as User_ID, candidate0_.LogonName as LogonName, candidate0_.Password as Password, candidate0_.Country as Country, candidate0_.ethnicOrigin as ethnicOr4_, candidate0_.Gender as Gender, candidate0_.maritalStatus as maritalS6_, candidate0_.cellPhoneNumber as cellPhon7_, candidate0_.fName as fName, candidate0_.lName as lName, candidate0_.Anniversary as Anniver10_, candidate0_.birthDate as birthDate, candidate0_.children as children, candidate0_.isCompanyContract as isCompa13_, candidate0_.HotTopic as HotTopic, candidate0_.interests as interests, candidate0_.isMatrixEmployee as isMatri16_, candidate0_.MatrixEmployeeType as MatrixE17_, candidate0_.pagerNumber as pagerNu18_, candidate0_.pagerPin as pagerPin, candidate0_.significantDates as signifi20_, candidate0_.title as title, candidate0_.url as url from DB2ADMIN.User candidate0_ where candidate0_.subclass='C'
2004-02-24 15:13:34,440 [main] DEBUG hibernate.impl.BatcherImpl(196) -> about to open: 0 open PreparedStatements, 0 open ResultSets
2004-02-24 15:13:34,440 [main] DEBUG sf.hibernate.SQL(237) -> select candidate0_.User_ID as User_ID, candidate0_.LogonName as LogonName, candidate0_.Password as Password, candidate0_.Country as Country, candidate0_.ethnicOrigin as ethnicOr4_, candidate0_.Gender as Gender, candidate0_.maritalStatus as maritalS6_, candidate0_.cellPhoneNumber as cellPhon7_, candidate0_.fName as fName, candidate0_.lName as lName, candidate0_.Anniversary as Anniver10_, candidate0_.birthDate as birthDate, candidate0_.children as children, candidate0_.isCompanyContract as isCompa13_, candidate0_.HotTopic as HotTopic, candidate0_.interests as interests, candidate0_.isMatrixEmployee as isMatri16_, candidate0_.MatrixEmployeeType as MatrixE17_, candidate0_.pagerNumber as pagerNu18_, candidate0_.pagerPin as pagerPin, candidate0_.significantDates as signifi20_, candidate0_.title as title, candidate0_.url as url from DB2ADMIN.User candidate0_ where candidate0_.subclass='C'
2004-02-24 15:13:34,440 [main] DEBUG hibernate.impl.BatcherImpl(241) -> preparing statement
2004-02-24 15:13:34,518 [main] DEBUG hibernate.loader.Loader(197) -> processing result set
2004-02-24 15:13:34,534 [main] DEBUG hibernate.type.IntegerType(68) -> returning '44' as column: User_ID
2004-02-24 15:13:34,534 [main] DEBUG hibernate.loader.Loader(405) -> result row: 44
2004-02-24 15:13:34,549 [main] DEBUG hibernate.loader.Loader(536) -> Initializing object from ResultSet: 44
2004-02-24 15:13:34,549 [main] DEBUG hibernate.loader.Loader(605) -> Hydrating entity: com.matrix.mss.bo.user.candidate.Candidate#44
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: LogonName
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: Password
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.IntegerType(64) -> returning null as column: Country
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.IntegerType(64) -> returning null as column: ethnicOr4_
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.IntegerType(64) -> returning null as column: Gender
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.IntegerType(68) -> returning '65' as column: maritalS6_
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.StringType(68) -> returning '6784882991' as column: cellPhon7_
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.StringType(68) -> returning 'Johnny' as column: fName
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.StringType(68) -> returning 'Dangerously' as column: lName
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: Anniver10_
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.DateType(68) -> returning '20 February 1984' as column: birthDate
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.StringType(68) -> returning 'no children' as column: children
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.BooleanType(68) -> returning 'false' as column: isCompa13_
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: HotTopic
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: interests
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.BooleanType(68) -> returning 'false' as column: isMatri16_
2004-02-24 15:13:34,549 [main] DEBUG hibernate.type.CharacterType(68) -> returning '' as column: MatrixE17_
2004-02-24 15:13:34,565 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: pagerNu18_
2004-02-24 15:13:34,565 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: pagerPin
2004-02-24 15:13:34,565 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: signifi20_
2004-02-24 15:13:34,565 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: title
2004-02-24 15:13:34,565 [main] DEBUG hibernate.type.StringType(64) -> returning null as column: url
2004-02-24 15:13:34,565 [main] DEBUG hibernate.loader.Loader(226) -> done processing result set (1 rows)
2004-02-24 15:13:34,565 [main] DEBUG hibernate.impl.BatcherImpl(203) -> done closing: 0 open PreparedStatements, 0 open ResultSets
2004-02-24 15:13:34,565 [main] DEBUG hibernate.impl.BatcherImpl(261) -> closing statement
2004-02-24 15:13:34,565 [main] DEBUG hibernate.loader.Loader(239) -> total objects hydrated: 1
2004-02-24 15:13:34,565 [main] DEBUG hibernate.impl.SessionImpl(2166) -> resolving associations for [com.matrix.mss.bo.user.candidate.Candidate#44]
2004-02-24 15:13:34,565 [main] DEBUG hibernate.impl.SessionImpl(1950) -> loading [com.matrix.mss.bo.user.candidate.CandidateProfile#44]
2004-02-24 15:13:34,565 [main] DEBUG hibernate.impl.SessionImpl(2047) -> attempting to resolve [com.matrix.mss.bo.user.candidate.CandidateProfile#44]
2004-02-24 15:13:34,565 [main] DEBUG hibernate.impl.SessionImpl(2080) -> object not resolved in any cache [com.matrix.mss.bo.user.candidate.CandidateProfile#44]
2004-02-24 15:13:34,565 [main] DEBUG hibernate.persister.EntityPersister(416) -> Materializing entity: [com.matrix.mss.bo.user.candidate.CandidateProfile#44]
2004-02-24 15:13:34,565 [main] DEBUG hibernate.impl.BatcherImpl(196) -> about to open: 0 open PreparedStatements, 0 open ResultSets
2004-02-24 15:13:34,581 [main] DEBUG sf.hibernate.SQL(237) -> select candidatep0_.Candidate_ID as Candidat1_12_, candidatep0_.User_ID as User_ID12_, candidatep0_.EducationLevel_ID as Educatio3_12_, candidatep0_.WorkAuth_ID as WorkAuth4_12_, candidatep0_.IndustryCategory as Industry5_12_, candidatep0_.Experience_ID as Experien6_12_, candidatep0_.PSDRPlateStatus as PSDRPlat7_12_, candidatep0_.PSDRPlateType as PSDRPlat8_12_, candidatep0_.EducationVerified_ID as Educatio9_12_, candidatep0_.CASDate as CASDate12_, candidatep0_.EduLocation as EduLoca11_12_, candidatep0_.EduMajor as EduMajor12_, candidatep0_.BestContact as BestCon13_12_, candidatep0_.CertComments as CertCom14_12_, candidatep0_.LastReviewDate as LastRev15_12_, candidatep0_.YearInIS as YearInIS12_, candidatep0_.Appearance as Appearance12_, candidatep0_.CASOnFile as CASOnFile12_, candidatep0_.CommSkills as CommSkills12_, candidatep0_.EligWork as EligWork12_, candidatep0_.LeaveFactor as LeaveFa21_12_, candidatep0_.OtherNames as OtherNames12_, candidatep0_.PersonAttr as PersonAttr12_, candidate1_.User_ID as User_ID0_, candidate1_.LogonName as LogonName0_, candidate1_.Password as Password0_, candidate1_.Country as Country0_, candidate1_.ethnicOrigin as ethnicOr4_0_, candidate1_.Gender as Gender0_, candidate1_.maritalStatus as maritalS6_0_, candidate1_.cellPhoneNumber as cellPhon7_0_, candidate1_.fName as fName0_, candidate1_.lName as lName0_, candidate1_.Anniversary as Anniver10_0_, candidate1_.birthDate as birthDate0_, candidate1_.children as children0_, candidate1_.isCompanyContract as isCompa13_0_, candidate1_.HotTopic as HotTopic0_, candidate1_.interests as interests0_, candidate1_.isMatrixEmployee as isMatri16_0_, candidate1_.MatrixEmployeeType as MatrixE17_0_, candidate1_.pagerNumber as pagerNu18_0_, candidate1_.pagerPin as pagerPin0_, candidate1_.significantDates as signifi20_0_, candidate1_.title as title0_, candidate1_.url as url0_, keyword2_.Keyword_ID as Keyword_ID1_, keyword2_.Active as Active1_, keyword2_.AJCValue as AJCValue1_, keyword2_.ListKey as ListKey1_, keyword2_.ListSort as ListSort1_, keyword2_.ListValue as ListValue1_, keyword3_.Keyword_ID as Keyword_ID2_, keyword3_.Active as Active2_, keyword3_.AJCValue as AJCValue2_, keyword3_.ListKey as ListKey2_, keyword3_.ListSort as ListSort2_, keyword3_.ListValue as ListValue2_, keyword4_.Keyword_ID as Keyword_ID3_, keyword4_.Active as Active3_, keyword4_.AJCValue as AJCValue3_, keyword4_.ListKey as ListKey3_, keyword4_.ListSort as ListSort3_, keyword4_.ListValue as ListValue3_, keyword5_.Keyword_ID as Keyword_ID4_, keyword5_.Active as Active4_, keyword5_.AJCValue as AJCValue4_, keyword5_.ListKey as ListKey4_, keyword5_.ListSort as ListSort4_, keyword5_.ListValue as ListValue4_, keyword6_.Keyword_ID as Keyword_ID5_, keyword6_.Active as Active5_, keyword6_.AJCValue as AJCValue5_, keyword6_.ListKey as ListKey5_, keyword6_.ListSort as ListSort5_, keyword6_.ListValue as ListValue5_, keyword7_.Keyword_ID as Keyword_ID6_, keyword7_.Active as Active6_, keyword7_.AJCValue as AJCValue6_, keyword7_.ListKey as ListKey6_, keyword7_.ListSort as ListSort6_, keyword7_.ListValue as ListValue6_, keyword8_.Keyword_ID as Keyword_ID7_, keyword8_.Active as Active7_, keyword8_.AJCValue as AJCValue7_, keyword8_.ListKey as ListKey7_, keyword8_.ListSort as ListSort7_, keyword8_.ListValue as ListValue7_, keyword9_.Keyword_ID as Keyword_ID8_, keyword9_.Active as Active8_, keyword9_.AJCValue as AJCValue8_, keyword9_.ListKey as ListKey8_, keyword9_.ListSort as ListSort8_, keyword9_.ListValue as ListValue8_, keyword10_.Keyword_ID as Keyword_ID9_, keyword10_.Active as Active9_, keyword10_.AJCValue as AJCValue9_, keyword10_.ListKey as ListKey9_, keyword10_.ListSort as ListSort9_, keyword10_.ListValue as ListValue9_, keyword11_.Keyword_ID as Keyword_ID10_, keyword11_.Active as Active10_, keyword11_.AJCValue as AJCValue10_, keyword11_.ListKey as ListKey10_, keyword11_.ListSort as ListSort10_, keyword11_.ListValue as ListValue10_, keyword12_.Keyword_ID as Keyword_ID11_, keyword12_.Active as Active11_, keyword12_.AJCValue as AJCValue11_, keyword12_.ListKey as ListKey11_, keyword12_.ListSort as ListSort11_, keyword12_.ListValue as ListValue11_ from DB2ADMIN.Candidate candidatep0_ left outer join DB2ADMIN.User candidate1_ on candidatep0_.User_ID=candidate1_.User_ID left outer join DB2ADMIN.Keyword keyword2_ on candidate1_.Country=keyword2_.Keyword_ID left outer join DB2ADMIN.Keyword keyword3_ on candidate1_.ethnicOrigin=keyword3_.Keyword_ID left outer join DB2ADMIN.Keyword keyword4_ on candidate1_.Gender=keyword4_.Keyword_ID left outer join DB2ADMIN.Keyword keyword5_ on candidate1_.maritalStatus=keyword5_.Keyword_ID left outer join DB2ADMIN.Keyword keyword6_ on candidatep0_.EducationLevel_ID=keyword6_.Keyword_ID left outer join DB2ADMIN.Keyword keyword7_ on candidatep0_.WorkAuth_ID=keyword7_.Keyword_ID left outer join DB2ADMIN.Keyword keyword8_ on candidatep0_.IndustryCategory=keyword8_.Keyword_ID left outer join DB2ADMIN.Keyword keyword9_ on candidatep0_.Experience_ID=keyword9_.Keyword_ID left outer join DB2ADMIN.Keyword keyword10_ on candidatep0_.PSDRPlateStatus=keyword10_.Keyword_ID left outer join DB2ADMIN.Keyword keyword11_ on candidatep0_.PSDRPlateType=keyword11_.Keyword_ID left outer join DB2ADMIN.Keyword keyword12_ on candidatep0_.EducationVerified_ID=keyword12_.Keyword_ID where candidatep0_.Candidate_ID=?
2004-02-24 15:13:34,581 [main] DEBUG hibernate.impl.BatcherImpl(241) -> preparing statement
2004-02-24 15:13:34,581 [main] DEBUG hibernate.type.IntegerType(46) -> binding '44' to parameter: 1
2004-02-24 15:13:34,596 [main] DEBUG hibernate.loader.Loader(197) -> processing result set
2004-02-24 15:13:34,612 [main] DEBUG hibernate.loader.Loader(226) -> done processing result set (0 rows)
2004-02-24 15:13:34,612 [main] DEBUG hibernate.impl.BatcherImpl(203) -> done closing: 0 open PreparedStatements, 0 open ResultSets
2004-02-24 15:13:34,612 [main] DEBUG hibernate.impl.BatcherImpl(261) -> closing statement
2004-02-24 15:13:34,612 [main] DEBUG hibernate.loader.Loader(239) -> total objects hydrated: 0
2004-02-24 15:13:34,612 [main] DEBUG hibernate.impl.SessionImpl(3891) -> creating collection wrapper:[com.matrix.mss.bo.user.User.jobOrders#44]
2004-02-24 15:13:34,628 [main] DEBUG hibernate.impl.SessionImpl(3891) -> creating collection wrapper:[com.matrix.mss.bo.user.Person.addresses#44]
2004-02-24 15:13:34,628 [main] DEBUG hibernate.impl.SessionImpl(1950) -> loading [com.matrix.mss.bo.Keyword#65]
2004-02-24 15:13:34,628 [main] DEBUG hibernate.impl.SessionImpl(2047) -> attempting to resolve [com.matrix.mss.bo.Keyword#65]
2004-02-24 15:13:34,628 [main] DEBUG hibernate.impl.SessionImpl(2080) -> object not resolved in any cache [com.matrix.mss.bo.Keyword#65]
2004-02-24 15:13:34,628 [main] DEBUG hibernate.persister.EntityPersister(416) -> Materializing entity: [com.matrix.mss.bo.Keyword#65]
2004-02-24 15:13:34,628 [main] DEBUG hibernate.impl.BatcherImpl(196) -> about to open: 0 open PreparedStatements, 0 open ResultSets
2004-02-24 15:13:34,628 [main] DEBUG sf.hibernate.SQL(237) -> select keyword0_.Keyword_ID as Keyword_ID0_, keyword0_.Active as Active0_, keyword0_.AJCValue as AJCValue0_, keyword0_.ListKey as ListKey0_, keyword0_.ListSort as ListSort0_, keyword0_.ListValue as ListValue0_ from DB2ADMIN.Keyword keyword0_ where keyword0_.Keyword_ID=?
2004-02-24 15:13:34,628 [main] DEBUG hibernate.impl.BatcherImpl(241) -> preparing statement
2004-02-24 15:13:34,799 [main] DEBUG hibernate.type.IntegerType(46) -> binding '65' to parameter: 1
2004-02-24 15:13:34,831 [main] DEBUG hibernate.loader.Loader(197) -> processing result set
2004-02-24 15:13:34,831 [main] DEBUG hibernate.loader.Loader(405) -> result row: 65
2004-02-24 15:13:34,831 [main] DEBUG hibernate.loader.Loader(536) -> Initializing object from ResultSet: 65
2004-02-24 15:13:34,831 [main] DEBUG hibernate.loader.Loader(605) -> Hydrating entity: com.matrix.mss.bo.Keyword#65
2004-02-24 15:13:34,831 [main] DEBUG hibernate.type.BooleanType(68) -> returning 'true' as column: Active0_
2004-02-24 15:13:34,831 [main] DEBUG hibernate.type.StringType(68) -> returning 'Single' as column: AJCValue0_
2004-02-24 15:13:34,831 [main] DEBUG hibernate.type.StringType(68) -> returning 'MARITALSTATUS' as column: ListKey0_
2004-02-24 15:13:34,831 [main] DEBUG hibernate.type.IntegerType(68) -> returning '1' as column: ListSort0_
2004-02-24 15:13:34,831 [main] DEBUG hibernate.type.StringType(68) -> returning 'Single' as column: ListValue0_
2004-02-24 15:13:34,831 [main] DEBUG hibernate.loader.Loader(226) -> done processing result set (1 rows)
2004-02-24 15:13:34,831 [main] DEBUG hibernate.impl.BatcherImpl(203) -> done closing: 0 open PreparedStatements, 0 open ResultSets
2004-02-24 15:13:34,831 [main] DEBUG hibernate.impl.BatcherImpl(261) -> closing statement
2004-02-24 15:13:34,831 [main] DEBUG hibernate.loader.Loader(239) -> total objects hydrated: 1
2004-02-24 15:13:34,831 [main] DEBUG hibernate.impl.SessionImpl(2166) -> resolving associations for [com.matrix.mss.bo.Keyword#65]
2004-02-24 15:13:34,846 [main] DEBUG hibernate.impl.SessionImpl(2190) -> done materializing entity [com.matrix.mss.bo.Keyword#65]
2004-02-24 15:13:34,846 [main] DEBUG hibernate.impl.SessionImpl(2190) -> done materializing entity [com.matrix.mss.bo.user.candidate.Candidate#44]
2004-02-24 15:13:34,846 [main] DEBUG hibernate.impl.SessionImpl(3082) -> initializing non-lazy collections



Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2004 5:32 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
one-to-one means sharing the same id.

you have to use either an assigned generator or the foreign generator on the client side
Check the doc with the following keywords:
- one-to-one
- foriegn generator

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2004 5:51 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 2:14 pm
Posts: 40
Location: Atlanta, GA, USA
Thanks...

This is what I changed to get it working.

Code:
       <id
            name="id"
            column="Candidate_ID"
            type="int"
            unsaved-value="0"
        >
            <generator class="foreign">
                <param name="property">candidate</param>
            </generator>
        </id>

        <one-to-one
            name="candidate"
            class="com.matrix.mss.bo.user.candidate.Candidate"
            cascade="none"
            outer-join="auto"
            constrained="true"
        />


I do still have a question. What would the ID generator class need to be if I wanted to do it with unique foreign key associations ?

From 5.1.11. one-to-one of the docs
Alternatively, a foreign key with a unique constraint, from Employee to Person, may be expressed as:

<many-to-one name="person" class="Person" column="PERSON_ID" unique="true"/>
And this association may be made bidirectional by adding the following to the Person mapping:

<one-to-one name"employee" class="Employee" property-ref="person"/>


TIA


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2004 5:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Well you can use any id generator you want in that case, just like with a normal class.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.