I've got something like this in my model design:
Entity FooGroup {
...
- Set<@Foo> foos <-> fooGroups
...
}
Entity Foo {
...
- Set<@FooGroup> fooGroups inverse <-> foos
...
}
I wrote some repository test code (for my own sanity I like to know
that the base layers are working) and I have a simple delete test that
will find a known entity that I have defined in a db-unit xml file,
delete it, and then try to find it again to verify it has been deleted.
When I run the delete method, however, I get a hibernate exception
about a constraint violation on the join table - something that looks
like this when I try to delete an entity on either side of the
relationship.
----
Caused by: java.sql.SQLException: Integrity constraint violation
FK481738C0B905C605 table: FOO_FOOGROUP in statement [delete from
FOOGROUP where id=? and version=?]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
at
org
.apache
.commons
.dbcp
.DelegatingPreparedStatement
.executeUpdate(DelegatingPreparedStatement.java:101)
at
org
.hibernate
.persister
.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:
2528)
... 36 more
-----
If I change the relationship to be unidirectional, I can delete the
side that contains the link - but I still can't delete the side that
does not contain the
Is there something basic that I am forgetting to do?
The bi-directional many-to-many is not that important to me. I can
navigate a uni-directional graph just fine.
Do I have to rely on the parent of the collection to do the deleting
for me? (i.e. call a remove method to remove the item from its set,
and then call a Save and rely on a cascade-delete-orphan to do the
deleting?)
I will poke around more behind-the-scenes to see what is going on, but
I figured that this is such a basic issue that either I am doing
something stupid in my setup - or there is an easy explanation of how
I should be doing it.
Any help is appreciated.
Ryan
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Fornax-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fornax-developer