openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phill <>
Subject OneToMany cascading persist and sequence ID generator
Date Wed, 02 Mar 2011 14:49:55 GMT
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:
@SequenceGenerator(name = "Lead_Id_Gen", sequenceName = "lead_id_seq")

@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>();
@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?

View raw message