On 15 Jun 2026, at 22:54, Graham Leggett <[email protected]> wrote:

> After upgrading from torque3.3 to torque7 (big jump), I have everything 
> compiling, but what has suddenly vanished are autoincrementing database 
> primary keys for postgres.

Stepping through more code, I get here:

    public ObjectKey<?> doInsert(
            final ColumnValues insertValues,
            final Connection connection)
                    throws TorqueException
    {
        if (insertValues == null)
        {
            throw new TorqueException("insertValues is null");
        }
        if (connection == null)
        {
            throw new TorqueException("connection is null");
        }
        String databaseNameFromInsertValues = insertValues.getDbName();
        if (databaseNameFromInsertValues == null)
        {
            databaseNameFromInsertValues = getDatabaseName();
        }
        Database database = Torque.getDatabase(databaseNameFromInsertValues);
        Object keyInfo = getIdMethodInfo();
        IdGenerator keyGen = database.getIdGenerator(
                getTableMap().getPrimaryKeyMethod());

        SimpleKey<?> id = null;
        // can currently generate only single column pks, therefore a single
        // columnMap is ok
        ColumnMap primaryKey = null;
        if (keyGen != null)
        {
            // fail on multiple pks
            primaryKey = getTableMap().getPrimaryKey();

            // primaryKey will be null if there is no primary key
            // defined for the table we're inserting into.
            if (keyGen.isPriorToInsert() && primaryKey != null
                    && !insertValues.containsKey(primaryKey))
            {
                id = getId(primaryKey, keyGen, connection, keyInfo);
                insertValues.put(
                        primaryKey,
                        new JdbcTypedValue(id.getValue(), id.getJdbcType()));
            }
        }


The above code appears to have picked up the 
org.apache.torque.adapter.HsqldbAdapter based on the JDBC driver in the unit 
tests, instead of postgres as defined in the maven torque plugin:

                <torque.targetDatabase>postgresql</torque.targetDatabase>

hsqldb was previously in postgres-mode using sql.syntax_pgs=true; - does that 
no longer work?

Regards,
Graham
--


Reply via email to