openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Bauer <techhu...@gmail.com>
Subject Re: OneToMany cascading persist and sequence ID generator
Date Wed, 02 Mar 2011 15:22:22 GMT
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 <phill@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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message