I want to add a NOT NULL constraint to my table on my OrderColumn. Running my code with the constraint I get a constraint violation error. Running without the constraint I see that the row is first inserted without the OrderColumn, and then updated immediately after with the correct OrderColumn. Is there a reason for this behavior?
My entity managing the OrderColumn:
@Entity
@Table(name="INSPECTION")
public class Inspection implements Serializable
{
...
@OneToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE}, orphanRemoval=true)
@OrderColumn(name="LIST_INDEX", nullable=false)
@JoinColumn(name="INSPECTION_ID")
private List<RecommendationInstance> recommendations;
...
}
This question stemmed from Why is JPA ignoring my @OrderColumn in a basic use case? where I was confused as to why my OrderColumn wasn't getting inserted. Additional code samples can be seen there.