Hi,
I'm working with the following:
h2 - 1.3.164
Hibernate - 4.1.0.Final
I have a Role entity:
@Entity
public class Role implements IEntity{
@Id @GeneratedValue( strategy = GenerationType.AUTO ) @Column( name =
"ROLE_ID" ) private Long id;
@ManyToMany( fetch = FetchType.EAGER )
@JoinTable( joinColumns = { @JoinColumn( name =
"ROLE_ID",referencedColumnName = "ROLE_ID" ) },inverseJoinColumns = {
@JoinColumn( name = "PRIV_ID",referencedColumnName = "PRIV_ID" ) } )
private Set< Privilege > privileges;
}
And I'm running the following test:
Privilege existingPrivilege = privilegeService.create( new
Privilege( randomAlphabetic( 6 ) ) );
final Role newRole = new Role();
newRole.getPrivileges().add( existingPrivilege );
getService().create( newRole );
roleService.deleteAll();
Which essentially creates a Privilege, then adds it to a new role and
persists the role; then deletes all roles.
Everything works fine until the deleteAll call, which fails in H2 (but
works the way it should in MySQL):
...
Caused by: org.h2.jdbc.JdbcSQLException: Referential integrity constraint
violation: "FK81B4C22896D682CC: PUBLIC.ROLE_PRIVILEGE FOREIGN KEY(ROLE_ID)
REFERENCES PUBLIC.ROLE(ROLE_ID)"; SQL statement:
delete from Role [23503-164]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at
org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:398)
at
org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:415)
at
org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:291)
at org.h2.table.Table.fireConstraints(Table.java:862)
at org.h2.table.Table.fireAfterRow(Table.java:879)
at org.h2.command.dml.Delete.update(Delete.java:99)
at org.h2.command.CommandContainer.update(CommandContainer.java:73)
at org.h2.command.Command.executeUpdate(Command.java:226)
at
org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:143)
at
org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
... 65 more
I'm guessing this is a bug (I have seen some other, similar bugs open (or
resolved) in h2.
Should I open up a new issue for it?
Thanks.
Eugen.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/h2-database/-/NdgwvtnqIrQJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.