cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pascal Robert <prob...@druide.com>
Subject Re: Duplicate pk when inserting into an empty table
Date Fri, 05 May 2017 14:16:36 GMT
Forget that email. I commented out two other calls to context.commitChanges() in another block,
but I was still inserting objects.

> Le 5 mai 2017 à 10:10, Pascal Robert <probert@druide.com> a écrit :
> 
> Hi,
> 
> I’m using Cayenne 3.1.1 (moving from EOF) for a small project: migration data from
FileMaker to MySQL. I have one model with two data maps and two data nodes, one for FileMaker,
the other for MySQL. 
> 
> Everything works fine, except one thing: 
> 
>  java.sql.BatchUpdateException: Duplicate entry '753' for key ‘PRIMARY'
> 
> It seems that even if I commit changes after I set the new object, it tries to do a big
commit at the end. Code:
> 
>    SelectQuery select3 = new SelectQuery(Personnel.class);
>    List<Personnel> employes = context.performQuery(select3);
>    for (Personnel personnel: employes) {
>      Employe employeMySQL = context.newObject(Employe.class);
> 
>      if (personnel != null) {
>        employeMySQL.setMailing(personnel.getMailing());
>        employeMySQL.setPersNom(personnel.getPersNom());
>        context.commitChanges();
>      }
>    }
> 
> Personnel being an entity in FileMaker, Employe is the equivalent in MySQL. The primary
key in MySQL is an auto_increment field. The PK Generation Strategy is set to Database-Generated.
The table in MySQL doesn’t have any data (it was truncated before the inserts).


Mime
View raw message