Annette, Given your requirements of not changing the schema of the join table, this might be difficult. I believe the reason for your -407 sqlcode is because the insert is not providing a value for the defined primary key ANWDASEL_LFDNR. But, from a JPA perspective, the primary keys for a join table are the keys used by the tables that are being joined.
One thing that may help with understanding the problem is to use some of the OpenJPA tooling to generate the ddl for the tables in question. This would show how our expected table schemas map (or don't map) to your existing schema. For example, you could use the MappingTool to "validate" your object model against your data model. Reference the OpenJPA Manual for more information on the MappingTool (and other related tools): http://openjpa.apache.org/docs/latest/manual/manual.html#ref_guide_mapping_mappingtool_examples Hope this helps with understanding the problem. At this point, I can't offer any solutions (given your requirement not to modify the existing join table schema). Thanks, Kevin On Tue, May 27, 2008 at 4:56 AM, Scherer, Annette < [EMAIL PROTECTED]> wrote: > Hello OpenJPA users, > > > Can you help me solving following problem? > > > I want to persist the entity "Application" (see below) in 4 tables: > - table: ANW primary key column: ANW_NAME > - table: DA primary key column: > DA_NAME > - table: SEL primary key column: > SEL_LFDNR > - join table: ANWDASEL primary key column: > ANWDASEL_LFDNR > columns: > ANW_NAME, DA_NAME, SEL_LFDNR > > These tables are given. They cannot be changed. Especially the primary > key column ANWDASEL_LFDNR cannot be removed. > > > When doing so, I receive an SQLException: > <openjpa-1.0.2-r420667:627158 nonfatal general error> > org.apache.openjpa.persistence.PersistenceException: DB2 SQL error: > SQLCODE: -407, SQLSTATE: 23502, SQLERRMC: TBSPACEID=4, TABLEID=5, > COLNO=0 > {prepstmnt 1576164850 INSERT INTO T7.TAANWDASEL (ANW_NAME, SEL_LFDNR) > VALUES (?, ?) [params=(String) TestPersistAnw, (int) 101]} [code=-407, > state=23502]SQLCA OUTPUT[Errp=SQLDFMT1, Errd=-2146041828, 28, 0, 0, > -957, 0] > > > SQLCODE: -407 means: > SQL0407N Assignment of a NULL value to a NOT NULL column > "<name>" is not allowed. > > > > > > public class Application implements Serializable { > > @Column(name="ANW_NAME", length=50) > @Id private String name; > > @OneToMany(fetch=FetchType.EAGER, > cascade={CascadeType.ALL,CascadeType.REMOVE}) > @OrderBy > @JoinTable(name="TAANWDASEL", > [EMAIL PROTECTED](name="ANW_NAME", > referencedColumnName="ANW_NAME"),}, > [EMAIL PROTECTED](name="DA_NAME")) > private List<DomainAssociation> domainAssociations; > > @OneToMany(fetch=FetchType.EAGER, > cascade={CascadeType.ALL,CascadeType.REMOVE}) > @OrderBy > @JoinTable(name="TAANWDASEL", > [EMAIL PROTECTED](name="ANW_NAME", > referencedColumnName="ANW_NAME"),}, > [EMAIL PROTECTED](name="SEL_LFDNR")) > private List<Selection> selections; > } > > > > Thank yo for your advice > > > > > Annette Scherer >
