Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » History Policy(History policy is not working, the log shows that "Internal Exception: org.h2.jdbc.JdbcSQLException: NULL not allowed for column "PK"; SQL statement:")
History Policy [message #1784565] Thu, 29 March 2018 11:30 Go to next message
prabhanjan kumar is currently offline prabhanjan kumarFriend
Messages: 1
Registered: March 2018
Junior Member
Here is my entity setup:

@Table(name = "ENTITY_TBL")
public class EntityCls implements Serializable {

@Column(name = "TBL_ID")
private Long tblId;

@Column(name = "TBL_NAME", nullable = false)
@Size(min = 1, max = 255, message = "{name.size}")
@NotNull(message = "{name.required}")
private String tblName;

getters, setters


@Table(name = "ENTITY_HIST")
public class EntityHistory implements Serializable {

private Long pk;

@Column(name = "TBL_ID")
private Long tblId;

@Column(name = "TBL_NAME")
private String tblName;

@Column(name = "START")
private Date start;

@Column(name = "END")
private Date end;

getters, setters


public class EntityCustomizer implements DescriptorCustomizer {

public void customize(ClassDescriptor cd) throws Exception {
HistoryPolicy policy = new HistoryPolicy();


I can see insert statements generated in the log for ENTITY_TBL and ENTITY_HIST tables, but while inserting in history table ENTITY_HIST, the primary key is null and hence the exception is thrown.

"Internal Exception: org.h2.jdbc.JdbcSQLException: NULL not allowed for column "PK"; SQL statement:"

I have also tried other sequence strategy like sequence strategy but still not working as expected. Any help is appreciated.

Re: History Policy [message #1784830 is a reply to message #1784565] Wed, 04 April 2018 14:17 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
The history policy to use the ENTITY_HIST for the ENTITY_TBL history is outside of JPA. Your EntityHistory entity is adding in the ID field that is not used for history entries causing your problems - if you wish to map it as an entity, you are going to need to use a compound identifier composed of existing fields, like "TBL_ID" and "START" and possibly "END" to uniquely identify rows.
Previous Topic:Data too long for column error but it should fit
Next Topic:Oracle 12c support
Goto Forum:

Current Time: Fri May 27 00:53:43 GMT 2022

Powered by FUDForum. Page generated in 0.01961 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top