Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Postgresql with DataSource.sequenceMode and DataSourceField.implicitSequence

    Testing migration from SmartClient_v90p_2013-12-07_PowerEdition to SmartClient_v91p_2014-03-04_PowerEdition

    I am using Postgresql server 9.1. All my tables have a bigint type primary column which is auto-incremented by a custom next_id() function. Essentially for all practicle purposes from a JDBC client point of view this primarykey column behaves same as postgresql's inbuilt bigserial type.

    I am using the jdbc4 driver postgresql-9.0-801.jdbc4.jar with this project.

    In SmartClient_v90p_2013-12-07_PowerEdition all our datasource declarations are like : <field primaryKey="true" name="companyid" hidden="false" autoGenerated="true">
    So for any add operation smartclient is unable to retrieve the primary key of the just inserted row. To handle this for master-detail type pages, I had to employ tricks such as using cacheSyncOperation.

    When I saw the documentation of SmartClient_v91p_2014-03-04_PowerEdition for DataSource.sequenceMode and DataSourceField.implicitSequence at http://smartclient.com/docs/9.1/a/b/c/go.html#attr..DataSourceField.implicitSequence and http://smartclient.com/docs/9.1/a/b/c/go.html#attr..DataSource.sequenceMode, I hoped this problem was solved. By using getGeneratedKeys() smartclient would be able to get the last insert's primary key. But this is not happening.

    When I set <field name="orderid" autoGenerated="true" hidden="true" primaryKey="true" type="integer" implicitSequence="true"/> and sequenceMode="jdbcDriver" along with sql.USCProduction-localhost.default.sequence.mode=jdbcDriver in the server.properties, when I do a simple add operation, I see the following lines in the log :

    === 2014-03-06 11:39:40,104 [sor7] DEBUG SQLDriver - [builtinApplication.smaster_add] Discovered multiple generated keys via JDBC: {}
    === 2014-03-06 11:39:40,104 [sor7] DEBUG SQLDataSource - [builtinApplication.smaster_add] add operation affected 1 rows
    === 2014-03-06 11:39:40,104 [sor7] INFO SQLDataSource - [builtinApplication.smaster_add] primaryKeys: {}

    I dont understand the bit about "Discovered multiple generated keys via JDBC: {}", trying the insert on same table
    with a simple jsp using the same jdbc driver always returns a resultset with only one row with pk of the just inserted row via the stmt.getGeneratedKeys(); api.

    I am attaching complete log generated using the smartclientSDK of SmartClient_v91p_2014-03-04_PowerEdition ( taken via ./start_embedded_server.sh > log.log 2>&1), the ds.xml file and two jsp files one with smartclient form which demonstrates the above "Discovered multiple generated keys via JDBC: {}" in the log and another simple direct insert jsp which shows that the getGeneratedKeys(); api always returns the correct pk of last generated row. I am also enclosing the server.properties I am using for this.

    Is "Discovered multiple generated keys via JDBC: {}" with no pk's returned a bug? If not please help me understand correct usage of DataSource.sequenceMode and DataSourceField.implicitSequence.
    Attached Files

    #2
    Kudos for posting lots of details, but the key thing we need is the schema of your table. Without that, we can't run a test and see if we can replicate your results.

    Comment


      #3
      Here you go..
      Attached Files

      Comment


        #4
        This looks like a documentation error. The docs tell you that an implicitSequence field should not be of type "sequence", but this is wrong. Please try changing your field type from "integer" to "sequence" and let us know whether that fixes your issue.

        Thanks,
        Isomorphic Software Support

        Comment


          #5
          Yes changing the primary key field type from integer to sequence works. I get correct generated primary key back as can be see from below log excerpt :

          === 2014-03-08 09:32:18,778 [or12] DEBUG SQLDriver - [builtinApplication.ref:smaster_add] Discovered single generated key via JDBC: {orderid=1221353104246527}
          === 2014-03-08 09:32:18,778 [or12] DEBUG SQLDataSource - [builtinApplication.ref:smaster_add] add operation affected 1 rows
          === 2014-03-08 09:32:18,778 [or12] INFO SQLDataSource - [builtinApplication.ref:smaster_add] primaryKeys: {orderid=1221353104246527}

          Thanks and please correct the docs.

          Comment

          Working...
          X