| Hibernate version = 2.1
Database - Sybase Anywhere 7.0.4
 
 I have a class called as StoreRemoteSite which extends RemoteSite. There is a one-to-one association between StoreRemoteSite and RemoteSite. The mapping for this works fine. The SchemaExport utility creates the tables correctly. However, StoreRemoteSite needs to have an additional column that is a foreig-key to a Store table. The persistant class for the Store table is called as Store. However, this class is legacy code and is not mapped via hibernate. Also, I do not have access to the Store class. Is there any way, I can generate appropriate mapping for StoreRemoteSite so that it also can reference the unmapped Store class.
 
 The following are the classes that I am using..
 /**
 *
 *  @hibernate.class table="Remote_Site" schema="dev_group"
 *
 */
 public class RemoteSite
 {
 private String _id = null;
 private String _ipAddress = null;
 private String _recordVersion = null;
 private String _shortDescription = null;
 private String _longDescription = null;
 private Set _machines = null;
 public RemoteSite()
 {
 super();
 }
 /**
 *  @hibernate.id generator-class="uuid.hex" column="I_REMOTE_SITE_ID"
 */
 public String getId()
 {
 return this._id;
 }
 public void setId(String value)
 {
 this._id = value;
 }
 /**
 *  @hibernate.property column="Ip_Address" length="256" not-null="true"
 */
 public String getIpAddress()
 {
 return _ipAddress;
 }
 public void setIpAddress(String _ipAddress)
 {
 this._ipAddress = _ipAddress;
 }
 /**
 *  @hibernate.version column="Record_Version" type="com.pinncorp.framework.hibernate.UUIDType"
 */
 public String getRecordVersion()
 {
 return _recordVersion;
 }
 public void setRecordVersion(String _recordVersion)
 {
 this._recordVersion = _recordVersion;
 }
 /**
 * Retrieves RemoteMachine entities from the database that belong to this remote site.
 *
 * @hibernate.set role="machines" inverse="true" lazy="true" cascade="all"
 * @hibernate.collection-key column="I_Remote_Site_Id"
 * @hibernate.collection-one-to-many class="com.pinncorp.distmngr.common.remotesite.RemoteMachine"
 */
 public Set getRemoteMachines()
 {
 return _machines;
 }
 public void setRemoteMachines(Set remoteMachines)
 {
 this._machines = remoteMachines;
 }
 /**
 *  @hibernate.property column="Short_Description" length="25" not-null="true"
 */
 public String getShortDescription()
 {
 return _shortDescription;
 }
 public void setShortDescription(String shortDescription)
 {
 this._shortDescription = shortDescription;
 }
 /**
 *  @hibernate.property column="Long_Description" length="60" not-null="true"
 */
 public String getLongDescription()
 {
 return _longDescription;
 }
 public void setLongDescription(String longDescription)
 {
 this._longDescription = longDescription;
 }
 /**
 * This method returns the configuration for all application instances that reside in
 * each machine owned by the remote site.
 *
 * @return String : The entire configuration for the remote site as an XML String
 */
 public String getConfiguration(Date date)
 {
 StringBuffer xmlConfig = new StringBuffer( );
 
 //Add XML Header document.
 
 //For each machine
 for ( Iterator ir = _machines.iterator(); ir.hasNext(); )
 {
 RemoteMachine machine = ( RemoteMachine ) ir.next();
 xmlConfig.append( machine.getConfiguration( date ) );
 }
 
 return xmlConfig.toString();
 }
 }
 
 /**
 *  @hibernate.joined-subclass schema="dev_group"
 *  @hibernate.joined-subclass-key column="I_Remote_Site_Id"
 */
 public class StoreRemoteSite extends RemoteSite
 {
 private Store _store = null;
 
 public StoreRemoteSite()
 {
 super();
 }
 
 /**
 *  @hibernate.one-to-one class="com.pinncorp.sysmngr.store.Store"
 *                        cascade="all"
 */
 public Store getStore( )
 {
 return _store;
 }
 public void setStore( Store store )
 {
 this._store = store;
 }
 }
 
 The generated mapping files are as follows....
 <?xml version="1.0"?>
 
 <!DOCTYPE hibernate-mapping PUBLIC
 "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
 "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
 
 <hibernate-mapping>
 <class
 name="com.pinncorp.distmngr.common.remotesite.RemoteSite"
 table="Remote_Site"
 schema="dev_group"
 dynamic-update="false"
 dynamic-insert="false"
 >
 
 <id
 name="id"
 column="I_REMOTE_SITE_ID"
 type="java.lang.String"
 >
 <generator class="uuid.hex">
 </generator>
 </id>
 
 <version
 name="recordVersion"
 type="com.pinncorp.framework.hibernate.UUIDType"
 column="Record_Version"
 access="property"
 unsaved-value="undefined"
 />
 
 <property
 name="ipAddress"
 type="java.lang.String"
 update="true"
 insert="true"
 access="property"
 column="Ip_Address"
 length="256"
 not-null="true"
 />
 
 <set
 name="remoteMachines"
 lazy="true"
 inverse="true"
 cascade="all"
 sort="unsorted"
 >
 
 <key
 column="I_Remote_Site_Id"
 >
 </key>
 
 <one-to-many
 class="com.pinncorp.distmngr.common.remotesite.RemoteMachine"
 />
 </set>
 
 <property
 name="shortDescription"
 type="java.lang.String"
 update="true"
 insert="true"
 access="property"
 column="Short_Description"
 length="25"
 not-null="true"
 />
 
 <property
 name="longDescription"
 type="java.lang.String"
 update="true"
 insert="true"
 access="property"
 column="Long_Description"
 length="60"
 not-null="true"
 />
 
 <!--
 To add non XDoclet property mappings, create a file named
 hibernate-properties-RemoteSite.xml
 containing the additional properties and place it in your merge dir.
 -->
 
 <joined-subclass
 name="com.pinncorp.distmngr.common.remotesite.StoreRemoteSite"
 schema="dev_group"
 dynamic-update="false"
 dynamic-insert="false"
 >
 <key
 column="I_Remote_Site_Id"
 />
 
 <one-to-one
 name="store"
 class="com.pinncorp.sysmngr.store.Store"
 cascade="all"
 outer-join="auto"
 constrained="false"
 />
 
 </joined-subclass>
 
 </class>
 
 </hibernate-mapping>
 
 
 And here's the table DDLs created by SchemaExport...
 
 create table dev_group.StoreRemoteSite
 (
 I_Remote_Site_Id VARCHAR(255) not null,
 primary key (I_Remote_Site_Id)
 );
 
 create table dev_group.Remote_Site (
 I_REMOTE_SITE_ID VARCHAR(255) not null,
 Record_Version VARCHAR(255) not null,
 Ip_Address VARCHAR(256) not null,
 Short_Description VARCHAR(25) not null,
 Long_Description VARCHAR(60) not null,
 primary key (I_REMOTE_SITE_ID)
 );
 
 create table dev_group.Remote_Machine (
 I_REMOTE_MACHINE_ID VARCHAR(255) not null,
 Record_Version VARCHAR(255) not null,
 Description VARCHAR(25) not null,
 Ip_Address VARCHAR(256) not null,
 I_Remote_Site_Id VARCHAR(255) not null,
 primary key (I_REMOTE_MACHINE_ID)
 );
 alter table dev_group.StoreRemoteSite add constraint FKC5AB604E90C884F0 foreign key (I_Remote_Site_Id) references dev_group.Remote_Site;
 
 alter table dev_group.Remote_Machine add constraint FK99C9A14E90C884F0 foreign key (I_Remote_Site_Id) references dev_group.Remote_Site;
 
 My actual question is how would I create a mapping in my StoreRemoteSite class so that the table dev_group.StoreRemoteSite, also, has another column that is a foreign key to my Store table eventhough the Store class is an unmapped object?
 
 
 |