I want to integrate a JDBC based application into an Java EE application running in GlassFish which uses EclipseLink JPA 2.5 with MariaDB (a MySQL clone).
The JDBC based application imports data from flat files into some database tables and requires to update the next serial value for the primary keys by executing:
UPDATE dbtable SET nextid = 4711 WHERE name = 'table4Import';
using a standard JDBC connection. This statement throws an SQL timeout exception because the row is locked. It seems to be locked by EclipseLink which uses the same table for its table generator. Here is (parts of) the table containing the serial values:
CREATE TABLE dbtable (
dbtid bigint not null primary key,
dbtname varchar ( 50 ) not null,
dbtnextid bigint );
This is the code for one of the JPA entities:
@Entity
@Access(AccessType.PROPERTY)
@Table( name = "table4Import" )
public class Table4ImportClass {
private Long id = null;
@NotNull
@Id
@TableGenerator( name="table4Import", allocationSize=1,
table="dbtable", pkColumnName="dbtname",
pkColumnValue="table4Import", valueColumnName="nextid" )
@GeneratedValue( generator="table4Import", strategy=GenerationType.TABLE )
public Long getId() { return this.id; }
...
Addendum: It is not even possible to insert a new row into that table. EclipseLink seems to lock the complete table. It is still possible to modify the table (insert & update) from another program. The lock scope seems to be the JVM in which EclipseLink is running.
Addendum 2: Put this as a bug into EclipseLink bug tracker 455756