openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scherer, Annette" <Annette.Sche...@huk-coburg.de>
Subject @JoinTable between 3 tables
Date Tue, 27 May 2008 09:56:48 GMT
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",
joinColumns={@JoinColumn(name="ANW_NAME",
referencedColumnName="ANW_NAME"),},
inverseJoinColumns=@JoinColumn(name="DA_NAME"))
	private List<DomainAssociation> domainAssociations;
	
	@OneToMany(fetch=FetchType.EAGER,
cascade={CascadeType.ALL,CascadeType.REMOVE})
	@OrderBy
	@JoinTable(name="TAANWDASEL",
joinColumns={@JoinColumn(name="ANW_NAME",
referencedColumnName="ANW_NAME"),},
inverseJoinColumns=@JoinColumn(name="SEL_LFDNR"))
	private List<Selection> selections;
}
	


Thank yo for your advice




Annette Scherer

Mime
View raw message