samedi 12 décembre 2015

SQLite: java.lang.IllegalStateException:Could not create data element in dao, java.sql.SQLException: generated-id key was not set by the update call

Following is the structure of object which I am trying to insert....
1. Order and order_details table are there.
2. order object have foreign collection of order_details.
3. Both the objects have primary key as generatedId.
4. Exception comes when frequent insertions are done.

Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Could not create data element in dao
at com.j256.ormlite.dao.BaseForeignCollection.add(BaseForeignCollection.java:56)
at
Caused by: java.sql.SQLException: Unable to run insert stmt on object com.limetray.pos.models.PosOrderDetails@1c5fa91: INSERT INTO `pos_order_details` (`price` ,`product_id` ,`product_price_id` ,`product_description` ,`product_name` ,`tag_name` ,`quantity` ,`complimentary_quantity` ,`charge_group_id` ,`user_comments` ,`pos_order_id` ) VALUES (?,?,?,?,?,?,?,?,?,?,?)
at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:22)
at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:135)
at com.j256.ormlite.stmt.StatementExecutor.create(StatementExecutor.java:450)
at com.j256.ormlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:310)
at com.j256.ormlite.dao.BaseForeignCollection.addElement(BaseForeignCollection.java:195)
at com.j256.ormlite.dao.BaseForeignCollection.add(BaseForeignCollection.java:54)
... 48 more
Caused by: java.sql.SQLException: generated-id key was not set by the update call
at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:115)
... 52 more

Aucun commentaire:

Enregistrer un commentaire