Auto-generated key gets null pointer exception with MySQL

I am using CloverETL 3.0.1. I’ve coded a new graph that inserts a record and gets back a generated key. The first attempt at this yields the following exception:

ERROR [InsertPubObject_0] - java.lang.NullPointerException
DEBUG [InsertPubObject_0] - reset thread runId; runId:0 thread name:InsertPubObject_0
ERROR [WatchDog] - Graph execution finished with error
ERROR [WatchDog] - Node InsertPubObject finished with status: ERROR caused by: null caused by: java.lang.NullPointerException
ERROR [WatchDog] - Node InsertPubObject error details:
org.jetel.exception.JetelException: null caused by: java.lang.NullPointerException
at org.jetel.component.DBOutputTable.execute(DBOutputTable.java:664)
at org.jetel.graph.Node.run(Node.java:425)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
at org.jetel.connection.jdbc.AutoKeyGenerator.fieldMap(AutoKeyGenerator.java:216)
at org.jetel.connection.jdbc.AutoKeyGenerator.init(AutoKeyGenerator.java:157)
at org.jetel.connection.jdbc.AutoKeyGenerator.fillKeyRecord(AutoKeyGenerator.java:120)
at org.jetel.connection.jdbc.SQLCloverStatement.fillKeyRecord(SQLCloverStatement.java:664)
at org.jetel.connection.jdbc.SQLCloverStatement.executeUpdate(SQLCloverStatement.java:436)
at org.jetel.component.DBOutputTable.runInNormalMode(DBOutputTable.java:696)
at org.jetel.component.DBOutputTable.execute(DBOutputTable.java:640)
… 2 more

I debugged through this code, and it looks like the fillKeyRecord method is attempting to initialize the input record before actually creating the key record, but it dereferences that key record within the init call (leading to the null pointer exception).

Is there some configuration setting I need to do to set up auto_generated key records correctly?

I am using JDBC-specific MYSQL in the connection.

The insert statement looks like this:


INSERT INTO pub_object (tair_object_id, name, table_name, date_entered, date_updated, 
       entered_by, updated_by, date_last_synchronized)
VALUES ($tair_object_id, $name, ${table_name}, CURRENT_DATE, CURRENT_DATE, 75, 75, CURRENT_DATE)
RETURNING $id := auto_generated, $tair_object_id := $tair_object_id

Hello,

unfortunately the error message is not too descriptive. But according my investigation, this NPE is thrown in case the second output port is not attached.

See our DBOutputTable documentation
http://doc.cloveretl.com/documentation/ … table.html

The first output port is used for rejected records and the second port is used for auto-generated data fields and right this port needs to be attached.

Best regards, Martin

Yes, that was the problem–I accidentally put the generated output edge onto the first port in reshuffling the components. I corrected that and the graph now works as intended, thanks very much.

I would suggest adding a bug report to improve detection of the situation. Given that the SQL statement has a RETURNING clause, Clover does know there is an intention to generate keys, so a missing edge on Port 2 should raise a component error saying that a RETURNING clause is incompatible with no edge on Port 2 (rather than the current NPE, which as you say is not very informative).

Thanks again for your prompt help on this.

You are definitely right, I have reported the issue:

http://bug.javlin.eu/browse/CL-2343

Martin