EclipseLink @TableGenerator Concurrency Issue [message #1771597] |
Mon, 28 August 2017 13:15 |
Akhilesh Tripathi Messages: 2 Registered: August 2017 |
Junior Member |
|
|
I am using @TableGenerator to create primary id key sequences.
@Entity
@Table(name="PK_EVENT")
sequenceName="PK_EVT_SEQ")
@TableGenerator(
name="EVENTGEN",
table="PK_ID_GENERATOR",
pkColumnName="ID_KEY",
pkColumnValue="EVENT_ID",
valueColumnName="ID_VALUE",
allocationSize=1)
public class EventEntity implements Serializable,FDMSEntity
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.TABLE, generator="EVENTGEN")
generator="EVENTGEN")
@Column(name="EVENT_ID")
private long _eventId;
public long getEventId()
{
return _eventId;
}
public void setEventId(long p_eventId)
{
_eventId = p_eventId;
}
I have created "PKDS" as data source Weblogic 12c for connecting to SYBASE database. Created to persistence-unit PKDS-LOCAL type Resource_LOCAL & PKDS-JTA (type JTA)
"PKDS" data source is commanly shared between both persistence-units.
Now when I am running my multithreaded application. First I am issuing 'ERROR log event' to persist into PK_EVENT table using JTA txn, and immediately issuing 'INFO log event' to persist into PK_EVENT table using RESOURCE_LOCAL txn. then application waits untill JTA timeout time and return Error saying "message: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.sybase.jdbc3.jdbc.SybSQLException: Attempt to insert duplicate key row in object 'PK_EVENT' with unique index 'PK_EVENT_PK'
Error Code: 2601
Call: INSERT INTO PK_EVENT (EVENT_ID, DIRECTION, EVENT_MSG, EVENT_TIME, EVENT_TYPE, LINE_ID) VALUES (?, ?, ?, ?, ?, ?)
bind => [6 parameters bound]
Query: InsertObjectQuery(com.entity.EventEntity@7601127b)".
When I Check PK_EVENT table I see that INFO message of RESOURCE_LOCAL txn is persisted but error occurred for JTA txn which was issued first.
Please Help with possible way of resolution.
Thanks.
|
|
|
|
Powered by
FUDForum. Page generated in 0.05522 seconds