-->
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: Hibernate cannot fetch a one-to-one mapped data
PostPosted: Wed May 19, 2004 3:23 pm 
Beginner
Beginner

Joined: Tue Apr 06, 2004 6:13 pm
Posts: 39
Location: Pune, Maharashtra, INDIA
Hi

I hv 2 tables
Code:
     Partner              and            Profile
  PK: partner_ID   -------\       PK:profile_ID
   ... other cols..        \.---> FK:partner_ID (ref. Partner table)
                                           ... other cols...

The association between the table as seen is ONE-to-ONE

My hydrated objects are as:
Code:
/**
* @hibernate.class table="PARTNER"
*/
public class Partner {

   Integer partnerID;
   Profile profile;

   /**
    * @hibernate.id generator-class="native" type="long" column="PARTNER_ID"
    */
   public void getPartnerID() {
      return partnerID
   }

   /**
    * @hibernate.one-to-one name="profile" constrained="true" class="Profile"
    *                      cascade="all" outer-join="true" property-ref="partnerId"
    */
   public void getProfile() {
      return profile
   }
}

and
Code:
/**
* @hibernate.class table="PROFILE"
*/
public class Profile {

   Integer profileID;
   Integer partnerID;   //FK

   /**
    * @hibernate.id generator-class="native" type="long" column="PROFILE_ID"
    */
   public void getProfileID() {
      return profileID;
   }

   /**
    * @hibernate.property column="PARTNER_ID" length="9"
    */
   public void getPartnerID() {
      return partnerID
   }
}


In a test code I do, a

partner = Partner.findByPartnerCode("FMW"); //this method exists but is not shown above
Profile sp = partner.getProfile();

but I get an exception
No row with the given identifier exists: 858, of class: <packagename>.Profile

But in database values do exist.

I cannot figure out why?
I feel the hibernate Xdoclet I hv for one-to-one is not correct, but what is wrong is the mystery.

Any clues ?

_________________
thks
G1


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.