Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Postgresql with DataSource.sequenceMode and DataSourceField.implicitSequence

$
0
0
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
File Type: txt server.properties.txt (15.4 KB)
File Type: jsp smartclient_smaster_insert.jsp (1.1 KB)
File Type: jsp smasterinsert.jsp (2.1 KB)
File Type: xml smaster.ds.xml (382 Bytes)
File Type: txt log.txt (31.8 KB)

Viewing all articles
Browse latest Browse all 4756

Trending Articles