Hello,
here the specifications of the problem:
Hibernate version: hibernate-2.1.7c
Name of the database you are using: PointBase
* Class hierarchy:
- Java code:
Abstract class: abstract class SyntaxTreeComponent
Abstract class: abstract class Rule extends SyntaxTreeComponent
Concrete class: class ConditionalRule extends Rule
Abstract class: abstract class Operation extends SyntaxTreeComponent
Concrete class: class ComparisonOp extends Operation
- Graphical representation ('<-' = inherits):
Code:
(abstract) SyntaxTreeComponent <- (abstract) Rule <- ConditionalRule
<- (abstract) Operation <- ComparisonOp
* Polymorphic association: A conditional rule has an (abstract) operation.
* Mapping files: Used the 'table per subclass' strategy (reason: polymofism).
- SyntaxTreeComponent.hbm.xml:
Code:
<hibernate-mapping>
<class
name="SyntaxTreeComponent"
table="SYNTAX_TREE_COMPONENT">
<id
name="id"
column="SYNTAX_COMPONENT_ID"
type="long">
<generator class="native"/>
</id>
</class>
</hibernate-mapping>
- Operation.hbm.xml (Operation+ComparisonOp):
Code:
<hibernate-mapping>
<joined-subclass
name="Operation"
extends="SyntaxTreeComponent"
table="OPERATION">
<key column="OPERATION_ID"/>
<joined-subclass
name="ComparisonOp"
table="COMPARISON_OP">
<key column="COMPARISON_OP_ID"/>
</joined-subclass>
</joined-subclass>
</hibernate-mapping>
- Rule.hbm.xml (Rule+ConditionRule) CONTAINS THE PROBLEM ASSOCIATION:
Code:
<hibernate-mapping>
<joined-subclass
name="Rule"
extends="SyntaxTreeComponent"
table="RULE">
<key column="RULE_ID"/>
<joined-subclass
name="ConditionalRule"
table="CONDITIONAL_RULE">
<key column="CONDITIONAL_RULE_ID"/>
<many-to-one
name="operation"
class="Operation"
column="OPERATION_ID"
cascade="save-update"/>
</joined-subclass>
</joined-subclass>
</hibernate-mapping>
* Error messages: Code:
Code:
Rule rule = new ConditionalRule(new ComparisonOp());
...
session.save(rule);
...
Error:
Code:
JDBCExceptionReporter:58 - Referential Integrity Violation. CONDITIONAL_RULE references OPERATION
...
Caused by: java.sql.SQLException: Referential Integrity Violation. CONDITIONAL_RULE references OPERATION
Thanks in advance,
Johan