Re: Torque7 and postgresql autoincrementing primary keys not working

"Graham Leggett via torque-dev" <[email protected]> Mon, 15 Jun 2026 23:17:12 +0100
Newsgroups gmane.comp.jakarta.turbine.torque.devel
Message-ID <[email protected]>
--Apple-Mail=_6E8364FC-F90C-48BD-9F89-7F71711FAA0C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

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 =3D=3D null)
        {
            throw new TorqueException("insertValues is null");
        }
        if (connection =3D=3D null)
        {
            throw new TorqueException("connection is null");
        }
        String databaseNameFromInsertValues =3D =
insertValues.getDbName();
        if (databaseNameFromInsertValues =3D=3D null)
        {
            databaseNameFromInsertValues =3D getDatabaseName();
        }
        Database database =3D =
Torque.getDatabase(databaseNameFromInsertValues);
        Object keyInfo =3D getIdMethodInfo();
        IdGenerator keyGen =3D database.getIdGenerator(
                getTableMap().getPrimaryKeyMethod());

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

            // primaryKey will be null if there is no primary key
            // defined for the table we're inserting into.
            if (keyGen.isPriorToInsert() && primaryKey !=3D null
                    && !insertValues.containsKey(primaryKey))
            {
                id =3D 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=3Dtrue; - =
does that no longer work?

Regards,
Graham
--



--Apple-Mail=_6E8364FC-F90C-48BD-9F89-7F71711FAA0C--