Getting Unable to persist data entity, Error while commiting the transaction

781 views Asked by At

I successfully managed to write deployer extension as well as storage extension.

And below are the logs which I took from core logs, which shows everything is loaded perfectly!!

2013-01-08 11:30:19,759 INFO  BundleConfigurationLoader - Added 'PublishAction' for storage 'persistence' with 'com.tridion.storage.dao.JPAPublishActionDAO'.

2013-01-08 11:30:38,259 DEBUG JPAPublishActionDAO - Constructor of JPAPublishActionDAO- storageId:searchdb
2013-01-08 11:30:38,259 DEBUG JPAPublishActionDAO - Constructor of JPAPublishActionDAO- entityManagerFactory:true
2013-01-08 11:30:38,259 DEBUG JPAPublishActionDAO - Constructor of JPAPublishActionDAO- storageName:PublishAction

2013-01-08 11:19:38,400 INFO  Module - No TransformProcessor configured, will not transform files before deployment for module com.tridion.custom.extensions.SearchPageDeployer
2013-01-08 11:30:38,400 DEBUG SearchPageDeployer - Constructor of SearchPageDeployer //This is my PageDeployer Constructor


2013-01-08 11:30:38,744 DEBUG SearchPageDeployer - Called processPage from SearchPageDeployer //This is my process Page of pagedeployer class

2013-01-08 11:30:38,572 DEBUG SearchPageDeployer - SearchPageDeployer Called processItem
2013-01-08 11:30:38,572 DEBUG StorageManagerFactory - Default storage provider has caching set to: false
2013-01-08 11:30:38,572 DEBUG StorageManagerFactory - Loaded following dao Properties[publication=0, typeMapping=PublishAction, storageId=searchdb, cached=false] for publication/typeMapping/itemExtension: 0 / PublishAction / null
2013-01-08 11:30:38,572 DEBUG StorageManagerFactory - Loading a non cached DAO for publicationId/typeMapping/itemExtension: 0 / PublishAction / null
2013-01-08 11:30:38,572 DEBUG StorageManagerFactory - Wrapping DAO's, currently 0 wrappers installed
2013-01-08 11:30:38,572 INFO  JPAPublishActionDAO - Entering Method: JPAPublishActionDAO.PublishAction.store
2013-01-08 11:40:33,228 ERROR SearchPageDeployer - SearchPageDeployer - Exception occurred com.tridion.broker.StorageException: Unable to persist data entity, Error while commiting the transaction, Error while commiting the transaction

Now when I am trying to store the data in my table I am getting "Exception occurred com.tridion.broker.StorageException: Unable to persist data entity, Error while commiting the transaction, Error while commiting the transaction"

is this any issue with my Entity class or something I am missing.

EDIT: After the enable logger level "ON" in logback xml.

I got below exception in core files:

2013-01-08 14:42:10,713 DEBUG SQL - insert into AUTN_ITEMS (ACTION, FLAG, ITEM_TYPE, LAST_PUBLISHED_DATE, PUBLICATION_ID, SCHEMA_ID, TCMURI, URL, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
2013-01-08 14:42:10,728 DEBUG AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2013-01-08 14:42:10,744 DEBUG JDBCExceptionReporter - could not insert: [com.tridion.storage.dao.PublishAction] [insert into AUTN_ITEMS (ACTION, FLAG, ITEM_TYPE, LAST_PUBLISHED_DATE, PUBLICATION_ID, SCHEMA_ID, TCMURI, URL, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)]
com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert explicit value for identity column in table 'AUTN_ITEMS' when IDENTITY_INSERT is set to OFF.

Thanks

3

There are 3 answers

2
Daniel Neagu On BEST ANSWER

The error you're getting is suggesting that your ID column is not defined correctly as an identity or that you're trying to manually set a value to the autogenerated value in this column. Hope this helps.

Regards, Daniel.

0
Manoj Singh On

Above issue was in my Entity Class, I need to add below annotations for my identity column.

@Id
@Column(name = "ID", unique=true,updatable=false,insertable=false)
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;

Please do suggest if any changes are required.

Thanks

1
Mihai Cădariu On

The ID column should be set to auto increment at db level. Have a look at my original article on sdltridionworld for an example http://www.sdltridionworld.com/articles/sdltridion2011/tutorials/extending-content-delivery-storage-sdltridion-2011-1.aspx

"For SQL Server, column ID is defined as IDENTITY(1,1), so it increments automatically by one, without us having to specify value.

For Oracle, column ID needs to be defined using a Sequence (that generates the values), like this: CREATE SEQUENCE SEQ_PUBLISH_ACTIONS MAXVALUE 999999999999999 CYCLE START WITH 1 / CREATE OR REPLACE TRIGGER PUBLISH_ACTIONS_KEY BEFORE INSERT ON PUBLISH_ACTIONS FOR EACH ROW BEGIN   IF :new.ID IS NULL THEN     SELECT SEQ_PUBLISH_ACTIONS.NEXTVAL INTO :new.ID FROM DUAL;   END IF; END; / "