a foreign key constraint fails
The following code is used to check a number of properties:
entity Check {
user -> UserIdentity (inverse=UserIdentity.checks)
value :: Bool (default=false)
}entity UserIdentity {
// …checks -> List<Check> function init() { if(checks == null || checks.length < 10) { var i := 0; while(i < 10) { var c := Check{}; c.save(); checks.add(c); i := i + 1; } }
}
It causes the following error:
Submitted by Eelco Visser on 8 October 2011 at 15:26
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (researchr
._check
, CONSTRAINTFKA5FD57E9B8DF1731
FOREIGN KEY (Check_user
) REFERENCES_useridentity
(id
))
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
Issue Log
Is this local or on the server?
Log in to post comments