Hello there,

I'm attempting to write some code to build a development environment from a 
template database using Jooq 3.4.4.  I couldn't figure out how to re-use 
the same generated schema objects for both the input and the output 
databases, so I created two of them.  Mysql Enums appear to have been 
created by the generator and work perfectly serially through the create 
record interface.  However that doesn't seem to be the case with bind 
within batches.  I haven't yet got to JodaTime fields but that now has me 
worried.

I'm not sure if it's a problem with Jooq, or a problem with me.  I'm 
betting on me.

Exception in thread "main" org.jooq.exception.DataTypeException: Cannot 
convert from 1 (class java.lang.Integer) to class sourcedb.enums.ObjectType
at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:855)
at org.jooq.tools.Convert$ConvertAll.from(Convert.java:793)
at org.jooq.tools.Convert.convert0(Convert.java:299)
at org.jooq.tools.Convert.convert(Convert.java:291)
at org.jooq.tools.Convert.convert(Convert.java:352)
at org.jooq.impl.DefaultDataType.convert(DefaultDataType.java:608)
at org.jooq.impl.DSL.val(DSL.java:12149)
at org.jooq.impl.Utils.field(Utils.java:740)
at org.jooq.impl.Utils.fields(Utils.java:876)
at org.jooq.impl.BatchSingle.executePrepared(BatchSingle.java:145)
at org.jooq.impl.BatchSingle.execute(BatchSingle.java:116)


public static void transferRecords() {

    try (Connection connection = sourceConnectionPool.getConnection();) {

        DSLContext create = DSL.using(connection, SQLDialect.MYSQL);

        // Create object table entries

        BatchBindStep objectBatch = 
create.batch(create.insertInto(targetdb.Tables.OBJTABLE, OBJTABLE.TYPE, 
OBJTABLE.PARENT).values(null, (ULong)null));

        for (sourcedb.tables.records.ObjectRecord record : 
sourceDB.fetch(sourcedb.Tables.OBJTABLE, 
OBJTABLE.TYPE.equal(ObjectType.account))) {
            currentUUID = ULong.valueOf(currentUUID.longValue() + 1);

            uuidMap.put(record.getUid().intValue(), currentUUID.intValue());
            System.out.println("oldUUID:" + record.getUid() + " currentUUID: " 
+ currentUUID.longValue());

            objectBatch.bind(1, targetDB.enums.ObjectType.account);
            objectBatch.bind(2, record.getParent());

        }

        objectBatch.execute();

    } catch (SQLException e) {
        e.printStackTrace();
    }
}

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to