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:


Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (researchr._check, CONSTRAINT FKA5FD57E9B8DF1731 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)

Submitted by Eelco Visser on 8 October 2011 at 15:26

On 10 October 2011 at 09:01 Sander Vermolen commented:

Is this local or on the server?

Log in to post comments