I'm having some problems with a cascading @OneToMany persist, my class with the
@ManyToOne has a sequence id generator and this Id is not getting populated in
the cascaded entity.
Here are the relevant snippets:
Lead.java
------------------------------
@SequenceGenerator(name = "Lead_Id_Gen", sequenceName = "lead_id_seq")
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Lead_Id_Gen")
@Column(name = "lead_id")
private Long id;
@OneToMany(mappedBy = "lead", cascade = CascadeType.ALL)
private List<SurveyAnswer> answers = new ArrayList<SurveyAnswer>();
SurveyAnswer.java
------------------------------
@ManyToOne
@JoinColumn(name = "lead_id")
protected Lead lead;
org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR: null value in column
"lead_id" violates not-null constraint {prepstmnt 26568269
INSERT INTO survey_result (result_id, result_boolean, result_number,
result_int, result_text, answer_type, lead_id, survey_id,
question_id, single_choice)
Should this not happen automatically or am I missing something?
Thanks
Phill