Thanks, Phill. Sorry, I forgot to ask - does SurveyAnswer also use the same id generation strategy as Lead? In the meantime, I'll begin trying to reproduce the failure you are seeing.
-Jeremy On Wed, Mar 2, 2011 at 9:26 AM, Phill <ph...@bicispace.com> wrote: > OpenJPA 2.1.0 and PostgreSQL 9 > I have separate DDL. > Phill > > > On 02/mar/2011, at 16.22, Jeremy Bauer wrote: > > > Hi Phill, > > > > What database and version of OpenJPA are you using? Also, does OpenJPA > > generate the tables or do you have separate DDL? > > > > -Jeremy > > > > On Wed, Mar 2, 2011 at 8:49 AM, Phill <ph...@bicispace.com> wrote: > > > >> 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 > >