I've got an entity with a @GenericGenerator
:
@Entity
public class Report {
@Id
@GenericGenerator(name = "generator", strategy = "foreign",
parameters = @Parameter(name = "property", value = "examrequisitions"))
// @GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(nullable = false, unique = true)
private Long id;
... // outcome, status
}
When I save that entity it shows the following exception:
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null
Error Code: 1048
Call: INSERT INTO SystemCardiologyReports.REPORTS (ID, OUTCOME, STATUS) VALUES (?, ?, ?)
bind => [3 parameters bound]
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null
Why is the ID null
- despite the @GenericGenerator
?