-->
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.  [ 2 posts ] 
Author Message
 Post subject: one-to-one relation between two sub class in table?
PostPosted: Mon Sep 06, 2004 9:02 pm 
Newbie

Joined: Tue May 25, 2004 10:02 pm
Posts: 6
I want to implement this,two discriminator subclass,there is a one-to-one relation between two subclass,but It is a legacy schema,two subclass is in one table.
In detail,
Hibernate version:2.1.6


<?xml version="1.0" encoding="UTF-8"?>
<!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.caec.amis.model.DynFlight" table="dynflight" schema="dbo" dynamic-update = "true" dynamic-insert = "true">
<id name="flightid" type="long" column="flightid" unsaved-value="null" length="8">
<generator class="assigned"/>
</id>
<discriminator column="inoutflag" not-null="true" type="string" length="2"/>
<property name="execdate" type="timestamp"
column="execdate" not-null="true" length="23"/>


<property name="lightinguse" type="string" column="lightinguse" length="1"/>


<subclass name="com.caec.amis.model.ArrvialDynFlight" discriminator-value="A">
<one-to-one name="associateflight" foreign-key="fkarrvialtodepartflight" class="com.caec.amis.model.DepartDynFlight" cascade="all" constrained="true"/>
</subclass>
<subclass name="com.caec.amis.model.DepartDynFlight" discriminator-value="D">

<one-to-one name="associateflight" foreign-key="fkdeparttoarrvialflight" class="com.caec.amis.model.ArrvialDynFlight" cascade="all" constrained="true"/>

</subclass>







</class>
</hibernate-mapping>

java code:(using spring 1.1 final)

ArrvialDynFlight af = new ArrvialDynFlight();
af.setFlightid(new Long(1));
af.setExecdate(new Date());
af.setLightinguse("2");

DepartDynFlight df = new DepartDynFlight();
df.setFlightid(new Long(2));
df.setExecdate(new Date());
df.setLightinguse("3");
af.setAssociateflight(df);
df.setAssociateflight(af);
this.getHibernateTemplate().save(af);


debug info:
log4j:WARN No appenders could be found for logger (org.springframework.beans.factory.xml.XmlBeanDefinitionReader).
log4j:WARN Please initialize the log4j system properly.
org.springframework.orm.hibernate.HibernateSystemException: SQL insert, update or delete failed (row not found); nested exception is net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:684)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:642)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2372)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:460)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:373)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:241)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
at $Proxy1.find(Unknown Source)
at com.caec.amis.test.testdao.main(testdao.java:22)
Exception in thread "main"


I am not sure,it is possible?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 2:54 am 
Newbie

Joined: Tue May 25, 2004 10:02 pm
Posts: 6
sorry,Additional information,I use Sybase 12.5 for windows nt.


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