Ok, so I changed it to use the values() rather than the set() syntax: final ImagesRecord record = create.insertInto(Tables.IMAGES, Images .RESIZED_URL, Images.ORIGINAL_URL, Images.WIDTH, Images .HEIGHT).values(resizedUrl, pi.original.sourceUrl.toString(), pi.processed.getWidth(),pi.processed.getHeight()).returning(Images .ID).fetchOne(); This time record.getValue(Images.ID) returned the number 5, but still no new rows have appeared in the images table in the DB! This is very strange.
Ian. On Fri, Mar 9, 2012 at 4:32 PM, Ian Clarke <[email protected]> wrote: > I'm trying to insert a new row into a MySql table, which has an > autoincrement primary key called id. I want to insert the row, and then > get the newly created id: > > final ImagesRecord record = create.insertInto(Tables.IMAGES) > > .set(Images.RESIZED_URL, resizedUrl).set(Images.ORIGINAL_URL, > pi.original.sourceUrl.toString()).set(Images.WIDTH, > pi.processed.getWidth()).set(Images > .HEIGHT, pi.processed.getHeight()).returning(Images.ID).fetchOne(); > > System.out.println(record.getValue(Images.ID)); > > This prints "null" and no new record is created in the database, even > though no errors are reported... > > Any ideas? > > Ian. > -- Ian Clarke Blog: http://blog.locut.us/
