-->
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: Newbie: optional one-to-one association
PostPosted: Mon Jun 04, 2007 9:00 am 
Regular
Regular

Joined: Tue Apr 10, 2007 10:02 am
Posts: 56
I've read the docs and searched the forums and can't find an answer to this particular problem

I have two entities like....

Code:
public class BuildingDesign {
   ....
   private int fID;
   private String fTitle;
   ....
}

public class BuildingDesignLock {
   ...
   private int fLockID;
   private int fBuildingDesignID;
   private String fUserID;
   ...
}

CREATE TABLE `building_design` (
  `BuildingDesignID' int(11) NOT NULL auto_increment,
  `BuildingDesingTItle` varchar(50) NOT NULL,
  PRIMARY KEY  (`BuildingDesignID`),
)

CREATE TABLE `building_design_lock` (
  `LockID' int(11) NOT NULL auto_increment,
  `BuildingDesignID' int(11) NOT NULL,
  PRIMARY KEY  (`LockID`),
  UNIQUE KEY `BuildingDesignID (`BuildingDesignID`))


The 'lock' entity is optional and used to hold the name of a user that has placed a write lock over building design entity.

There is a 1 to 1/0 link (i.e. optional one-to-one) link from BuildingDesign to BuildingDesignLock.

I want to display a list of the building designs with their lock status. For this I've created a descendant class like...

Code:
public class BuildingDesignInfo extends BuildingDesign {
   ....
   private BuildingDesingLock fLock;
   ....
}


.... but in none of the examples can I find a way of defining an optional one to one association where the link is a foreign key in the second table.

Can this be done?
[/code]


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.