Environment: Appfuse v2.0M4 + Hibernate + MySQL
I encountered the following error while executing "mvn integration-test":
===================================================
[INFO] [dbunit:operation {execution: test}]
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error executing database operation: CLEAN_INSERT
Embedded error:
com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot
delete or update a parent row: a foreign key constraint fails
(`myproject/tree`, CONSTRAINT `FK276B9E18FFF134` FOREIGN KEY
(`PARENT_TREE_ID`) REFERENCES `tree` (`id`))
===================================================
During the integration-test:
* first, it recreates the tables
* second, it load the data from sample-data.xml, and then do some tests
successfully
* thirdly, it tries to load the data and the above error occurs.
The following are extract of my code and sample data:
Tree.java:
===================================================
// Note: this Tree is actually a Node
public class Tree extends BaseObject implements Serializable {
private Long id;
private String name;
private Long parentTreeId;
private Tree parentTree;
private List <Tree> childTreeList;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return this.id;
}
@Column(name = "PARENT_TREE_ID")
public Long getParentTreeId() {
return parentTreeId;
}
@ManyToOne
@JoinColumn(name="PARENT_TREE_ID", nullable=true, updatable=false,
insertable=false)
public Tree getParentTree() {
return parentTree;
}
@OneToMany(cascade=CascadeType.ALL)
@LazyCollection(LazyCollectionOption.TRUE)
@JoinColumn(name="PARENT_TREE_ID")
public List <Tree> getChildTreeList() {
return childTreeList;
}
===================================================
sample-data.xml:
===================================================
<table name='tree'>
<column>id</column>
<column>name</column>
<column>parent_tree_id</column>
<row>
<value>1</value>
<value>Tree 1</value>
<null/>
</row>
<row>
<value>2</value>
<value>Tree 2</value>
<null/>
</row>
<row>
<value>3</value>
<value>Tree 1-1</value>
<value>1</value>
</row>
<row>
<value>4</value>
<value>Tree 1-2</value>
<value>1</value>
</row>
<row>
<value>5</value>
<value>Tree 1-1-1</value>
<value>3</value>
</row>
<row>
<value>6</value>
<value>Tree 1-1-2</value>
<value>3</value>
</row>
</table>
===================================================
So my question is: how to avoid the FK constraint violation?
* by modifying pom.xml ???
* by modifying annotation in Tree.java ???
* or by whatever ???
TIA
--
View this message in context:
http://www.nabble.com/How-to-avoid-FK-constraint-violation-during-integration-test--tf3491427s2369.html#a9750783
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]