Thanks for your response, but I allready tried to solve it with a many-to-one mapping, but Hibernate still gives the following error:
Code:
16:50:27,375 ERROR JDBCExceptionReporter:58 - Referential Integrity Violation. ADVENTUREBUILDER.RULE references ADVENTUREBUILDER.OPERATION
16:50:27,375 ERROR SessionImpl:2399 - Could not synchronize database state with session
net.sf.hibernate.exception.GenericJDBCException: could not insert: [syntaxtree.Rule#1]
at net.sf.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:81)
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1332)
at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:467)
at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:429)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:37)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2438)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2391)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2260)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at managing.RuleManagerImpl.addRule(RuleManagerImpl.java:120)
at managing.RuleManagerImpl.main(RuleManagerImpl.java:160)
Caused by: java.sql.SQLException: Referential Integrity Violation. ADVENTUREBUILDER.RULE references ADVENTUREBUILDER.OPERATION
at com.pointbase.net.netJDBCPrimitives.handleResponse(Unknown Source)
at com.pointbase.net.netJDBCPrimitives.handlePrimitiveResponse(Unknown Source)
at com.pointbase.net.netJDBCPreparedStatement.executeUpdate(Unknown Source)
at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:457)
... 8 more
I have the following sheme:
Abstract class SyntaxComponent;
2 subclasses:
Class Rule extends SyntaxComponent;
Class Operation extends SyntaxComponent;And the subclass '
Rule' has an '
Operation' member value. And this gives the problems!
class Rule extends SyntaxComponent {
private Operation op;
...
}
I posted my mapping file below.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<!-- @author Stijn Deroo-Van Maele -->
<!-- SyntaxComponent.hbm.xml -->
<!-- ORM mapping for 'SyntaxComponent' class -->
<hibernate-mapping>
<class
name="syntaxtree.SyntaxComponent"
table="SYNTAX_COMPONENT">
<id
name="id"
column="SYNTAX_COMPONENT_ID"
type="long">
<generator class="native"/>
</id>
<property
name="name"
column="NAME"
not-null="false"
unique="false"
type="string"/>
<joined-subclass
name="syntaxtree.Operation"
table="OPERATION">
<key column="id"/>
<property
name="operatorType"
column="OPERATOR_TYPE"
type="string"
/>
<joined-subclass
name="syntaxtree.ComparisonOp"
table="COMPARISON_OP">
<key column="id"/>
</joined-subclass>
</joined-subclass>
<joined-subclass
name="syntaxtree.Rule"
table="RULE">
<key column="id"/>
<property
name="active"
column="ACTIVE"
type="boolean"
/>
<property
name="description"
column="DESCRIPTION"
type="string"
/>
<property
name="scope"
column="SCOPE"
type="int"
/>
<property
name="type"
column="TYPE"
type="int"
/>
<many-to-one name="operation" class="syntaxtree.Operation" column="OPERATION_ID" unique="true"/>
<!-- <one-to-one name="operation" class="syntaxtree.Operation" constrained="true"></one-to-one>-->
</joined-subclass>
</class>
</hibernate-mapping>
[/code]