Stefan, are you able to join us on irc://irc.codehaus.org/castor
After a first view on your information I still do not sure what really goes wrong with your depended objects. Can you please try to modify your code so that State._systemState gets initialized when you call SystemStates.addState() or removeState(). You should have a look at following test case and test objects in src/tests/ctf/jdo/tc2x/ package: TestDependent Master Detail Group you can run this test from the commandline by executing following commands for root directory of castor: build clean build tests test castor.sapdb.TC25 make sure to have adjusted src/tests/jdo/sapdb.xml to your needs before issueing above commands. Regards Ralf Stefan Lober schrieb: > Hello Ralf, > > I am sorry, I described the problem incorrectly. > The problem occurs only with 1:N relations. > I have attached the relevant DDL and mapping parts and > the the source files. I am working with Castor 0.9.9 > and SapDB 7.4. > In my example, I have the following relation: > > Systemstates 1 ------ n State > > I supposed that the key-generator generates values for > the field "id" in both tables AND the field > "systemstates" in table "state", when I call > db.create(systemStates), where systemStates is an > instance of Systemstates. > But the field "systemstates" is not initialized. > > Stefan > > --- Ralf Joachim <[EMAIL PROTECTED]> > schrieb: > >>Hi Stefan, >> >>this should normally work. Can you provide us with >>some more information >>e.g. castor version, database, mapping. >> >>Ralf >> >>Stefan Lober schrieb: >> >> >>>Hello, >>> >>>while working with Castor JDO, I came across the >>>following problem: >>>My database mapping file contains one top-level >>>element which references the other elements. All >>>referenced elements are declared with "depends" set >> >>to >> >>>the top-level element. Thus, they are dependent on >>>this element. All elements have "key-generator" set >> >>to >> >>>"MAX". >>>When I try to insert a set of data by calling >>>db.create(...) with the top-level element as >> >>parameter >> >>>and no keys initialized for any element in the >>>hierarchy, I get an exception from my database >> >>which >> >>>tells me "Missing non-NULL value". This occurs >> >>because >> >>>the id (foreign key) for the referenced elements >> >>have >> >>>not been initialized. >>>Is the Key-Generator not supposed to initialize >>>private keys (set by "identity") AND the respective >>>foreign keys? >>> >>>Stefan >>> >>> >>> >>> >>> >>> >> >>___________________________________________________________ >> >> >>>Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher >> >>kostenlos - Hier anmelden: http://mail.yahoo.de >> >>>------------------------------------------------- >>>If you wish to unsubscribe from this list, please >>>send an empty message to the following address: >>> >>>[EMAIL PROTECTED] >>>------------------------------------------------- >>> >>> >> >>------------------------------------------------- >>If you wish to unsubscribe from this list, please >>send an empty message to the following address: >> >>[EMAIL PROTECTED] >>------------------------------------------------- >> >> > > > > > > > > > ___________________________________________________________ > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: > http://mail.yahoo.de > > > ------------------------------------------------------------------------ > > drop table Systemstates > // > > create table Systemstates ( > id integer not null, > primary key(id) > ) > // > > drop table State > // > > create table State ( > id integer not null, > stateMoment varchar(200), > stamptime varchar(200), > systemstates integer not null, > content varchar(200), > primary key(id) > ) > > > ------------------------------------------------------------------------ > > <class cst:name="log.Systemstates" cst:depends="log.Log1" cst:identity="id" > cst:key-generator="MAX"> > <description>Default mapping for class log.Systemstates</description> > <map-to cst:table="Systemstates" cst:xml="systemstates"/> > <field cst:name="id" cst:type="integer"> > <sql name="id" type="integer" dirty="check"/> > <bind-xml name="id" node="attribute"/> > </field> > <field cst:name="state" cst:type="log.State" cst:required="true" > cst:collection="array"> > <sql many-key="state" dirty="check"/> > <bind-xml name="state" node="element"/> > </field> > </class> > <class cst:name="log.State" cst:depends="log.Systemstates" cst:identity="id" > cst:key-generator="MAX"> > <description>Default mapping for class log.State</description> > <map-to cst:table="State" cst:xml="state"/> > <field cst:name="id" cst:type="integer"> > <sql name="id" type="integer" dirty="check"/> > <bind-xml name="id" node="attribute"/> > </field> > <field cst:name="stateMoment" cst:type="string" cst:required="true"> > <sql name="stateMoment" type="char" dirty="check"/> > <bind-xml name="state-moment" node="attribute"/> > </field> > <field cst:name="stamptime" cst:type="string" cst:required="true"> > <sql name="stamptime" type="char" dirty="check"/> > <bind-xml name="stamptime" node="attribute"/> > </field> > <field cst:name="systemstates" cst:type="log.Systemstates"> > <sql name="systemstates" dirty="check"/> > <bind-xml name="systemstates" node="element"/> > </field> > <field cst:name="content" cst:type="string"> > <sql name="content" type="char" dirty="check"/> > <bind-xml name="PCDATA" node="text"/> > </field> > </class> > > > ------------------------------------------------------------------------ > > /* * This class was automatically generated with * Castor 0.9.9 > <http://www.castor.org>, using an XML * Schema. * $Id$ */ package log; > //---------------------------------/ //- Imported classes and packages > -/ //---------------------------------/ import java.io.IOException; > import java.io.Reader; import java.io.Serializable; import > java.io.Writer; import java.util.Enumeration; import java.util.Vector; > import org.exolab.castor.xml.MarshalException; import > org.exolab.castor.xml.Marshaller; import > org.exolab.castor.xml.Unmarshaller; import > org.exolab.castor.xml.ValidationException; import > org.xml.sax.ContentHandler; /** * Class Systemstates. * * @version > $Revision$ $Date$ */ public class Systemstates implements > java.io.Serializable { //--------------------------/ //- Class/Member > Variables -/ //--------------------------/ /** * Field _id */ private > int _id; /** * keeps track of state for field: _id */ private boolean > _has_id; /** * Field _stateList */ private java.util.Vector _stateList; > //----------------/ //- Constructors -/ //----------------/ public > Systemstates() { super(); _stateList = new Vector(); } //-- > log.Systemstates() //-----------/ //- Methods -/ //-----------/ /** * > Method addState * * * * @param vState */ public void addState(log.State > vState) throws java.lang.IndexOutOfBoundsException { > _stateList.addElement(vState); } //-- void addState(log.State) /** * > Method addState * * * * @param index * @param vState */ public void > addState(int index, log.State vState) throws > java.lang.IndexOutOfBoundsException { _stateList.insertElementAt(vState, > index); } //-- void addState(int, log.State) /** * Method deleteId * */ > public void deleteId() { this._has_id= false; } //-- void deleteId() /** > * Method enumerateState * * * * @return Enumeration */ public > java.util.Enumeration enumerateState() { return _stateList.elements(); } > //-- java.util.Enumeration enumerateState() /** * Returns the value of > field 'id'. * * @return int * @return the value of field 'id'. */ public > int getId() { return this._id; } //-- int getId() /** * Method getState > * * * * @param index * @return State */ public log.State getState(int > index) throws java.lang.IndexOutOfBoundsException { //-- check bounds > for index if ((index < 0) || (index > _stateList.size())) { throw new > IndexOutOfBoundsException("getState: Index value '"+index+"' not in > range [0.."+_stateList.size()+ "]"); } return (log.State) > _stateList.elementAt(index); } //-- log.State getState(int) /** * Method > getState * * * * @return State */ public log.State[] getState() { int > size = _stateList.size(); log.State[] mArray = new log.State[size]; for > (int index = 0; index < size; index++) { mArray[index] = (log.State) > _stateList.elementAt(index); } return mArray; } //-- log.State[] > getState() /** * Method getStateCount * * * * @return int */ public int > getStateCount() { return _stateList.size(); } //-- int getStateCount() > /** * Method hasId * * * * @return boolean */ public boolean hasId() { > return this._has_id; } //-- boolean hasId() /** * Method isValid * * * * > @return boolean */ public boolean isValid() { try { validate(); } catch > (org.exolab.castor.xml.ValidationException vex) { return false; } return > true; } //-- boolean isValid() /** * Method marshal * * * * @param out > */ public void marshal(java.io.Writer out) throws > org.exolab.castor.xml.MarshalException, > org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, > out); } //-- void marshal(java.io.Writer) /** * Method marshal * * * * > @param handler */ public void marshal(org.xml.sax.ContentHandler > handler) throws java.io.IOException, > org.exolab.castor.xml.MarshalException, > org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, > handler); } //-- void marshal(org.xml.sax.ContentHandler) /** * Method > removeAllState * */ public void removeAllState() { > _stateList.removeAllElements(); } //-- void removeAllState() /** * > Method removeState * * * * @param index * @return State */ public > log.State removeState(int index) { java.lang.Object obj = > _stateList.elementAt(index); _stateList.removeElementAt(index); return > (log.State) obj; } //-- log.State removeState(int) /** * Sets the value > of field 'id'. * * @param id the value of field 'id'. */ public void > setId(int id) { this._id = id; this._has_id = true; } //-- void > setId(int) /** * Method setState * * * * @param index * @param vState */ > public void setState(int index, log.State vState) throws > java.lang.IndexOutOfBoundsException { //-- check bounds for index if > ((index < 0) || (index > _stateList.size())) { throw new > IndexOutOfBoundsException("setState: Index value '"+index+"' not in > range [0.."+_stateList.size()+ "]"); } _stateList.setElementAt(vState, > index); } //-- void setState(int, log.State) /** * Method setState * * * > * @param stateArray */ public void setState(log.State[] stateArray) { > //-- copy array _stateList.removeAllElements(); for (int i = 0; i < > stateArray.length; i++) { _stateList.addElement(stateArray[i]); } } //-- > void setState(log.State) /** * Method unmarshal * * * * @param reader * > @return Systemstates */ public static log.Systemstates > unmarshal(java.io.Reader reader) throws > org.exolab.castor.xml.MarshalException, > org.exolab.castor.xml.ValidationException { return (log.Systemstates) > Unmarshaller.unmarshal(log.Systemstates.class, reader); } //-- > log.Systemstates unmarshal(java.io.Reader) /** * Method validate * */ > public void validate() throws org.exolab.castor.xml.ValidationException > { org.exolab.castor.xml.Validator validator = new > org.exolab.castor.xml.Validator(); validator.validate(this); } //-- void > validate() } > ------------------------------------------------------------------------ > > /* * This class was automatically generated with * Castor 0.9.9 > <http://www.castor.org>, using an XML * Schema. * $Id$ */ package log; > //---------------------------------/ //- Imported classes and packages > -/ //---------------------------------/ import java.io.IOException; > import java.io.Reader; import java.io.Serializable; import > java.io.Writer; import org.exolab.castor.xml.MarshalException; import > org.exolab.castor.xml.Marshaller; import > org.exolab.castor.xml.Unmarshaller; import > org.exolab.castor.xml.ValidationException; import > org.xml.sax.ContentHandler; /** * Class State. * * @version $Revision$ > $Date$ */ public class State implements java.io.Serializable { > //--------------------------/ //- Class/Member Variables -/ > //--------------------------/ /** * Field _id */ private int _id; /** * > keeps track of state for field: _id */ private boolean _has_id; /** * > Field _stateMoment */ private java.lang.String _stateMoment; /** * Field > _stamptime */ private java.lang.String _stamptime; /** * internal > content storage */ private java.lang.String _content = ""; /** * Field > _systemstates */ private log.Systemstates _systemstates; > //----------------/ //- Constructors -/ //----------------/ public > State() { super(); setContent(""); } //-- log.State() //-----------/ //- > Methods -/ //-----------/ /** * Method deleteId * */ public void > deleteId() { this._has_id= false; } //-- void deleteId() /** * Returns > the value of field 'content'. The field 'content' * has the following > description: internal content storage * * @return String * @return the > value of field 'content'. */ public java.lang.String getContent() { > return this._content; } //-- java.lang.String getContent() /** * Returns > the value of field 'id'. * * @return int * @return the value of field > 'id'. */ public int getId() { return this._id; } //-- int getId() /** * > Returns the value of field 'stamptime'. * * @return String * @return the > value of field 'stamptime'. */ public java.lang.String getStamptime() { > return this._stamptime; } //-- java.lang.String getStamptime() /** * > Returns the value of field 'stateMoment'. * * @return String * @return > the value of field 'stateMoment'. */ public java.lang.String > getStateMoment() { return this._stateMoment; } //-- java.lang.String > getStateMoment() /** * Returns the value of field 'systemstates'. * * > @return Systemstates * @return the value of field 'systemstates'. */ > public log.Systemstates getSystemstates() { return this._systemstates; } > //-- log.Systemstates getSystemstates() /** * Method hasId * * * * > @return boolean */ public boolean hasId() { return this._has_id; } //-- > boolean hasId() /** * Method isValid * * * * @return boolean */ public > boolean isValid() { try { validate(); } catch > (org.exolab.castor.xml.ValidationException vex) { return false; } return > true; } //-- boolean isValid() /** * Method marshal * * * * @param out > */ public void marshal(java.io.Writer out) throws > org.exolab.castor.xml.MarshalException, > org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, > out); } //-- void marshal(java.io.Writer) /** * Method marshal * * * * > @param handler */ public void marshal(org.xml.sax.ContentHandler > handler) throws java.io.IOException, > org.exolab.castor.xml.MarshalException, > org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, > handler); } //-- void marshal(org.xml.sax.ContentHandler) /** * Sets the > value of field 'content'. The field 'content' has * the following > description: internal content storage * * @param content the value of > field 'content'. */ public void setContent(java.lang.String content) { > this._content = content; } //-- void setContent(java.lang.String) /** * > Sets the value of field 'id'. * * @param id the value of field 'id'. */ > public void setId(int id) { this._id = id; this._has_id = true; } //-- > void setId(int) /** * Sets the value of field 'stamptime'. * * @param > stamptime the value of field 'stamptime'. */ public void > setStamptime(java.lang.String stamptime) { this._stamptime = stamptime; > } //-- void setStamptime(java.lang.String) /** * Sets the value of field > 'stateMoment'. * * @param stateMoment the value of field 'stateMoment'. > */ public void setStateMoment(java.lang.String stateMoment) { > this._stateMoment = stateMoment; } //-- void > setStateMoment(java.lang.String) /** * Sets the value of field > 'systemstates'. * * @param systemstates the value of field > 'systemstates'. */ public void setSystemstates(log.Systemstates > systemstates) { this._systemstates = systemstates; } //-- void > setSystemstates(log.Systemstates) /** * Method unmarshal * * * * @param > reader * @return State */ public static log.State > unmarshal(java.io.Reader reader) throws > org.exolab.castor.xml.MarshalException, > org.exolab.castor.xml.ValidationException { return (log.State) > Unmarshaller.unmarshal(log.State.class, reader); } //-- log.State > unmarshal(java.io.Reader) /** * Method validate * */ public void > validate() throws org.exolab.castor.xml.ValidationException { > org.exolab.castor.xml.Validator validator = new > org.exolab.castor.xml.Validator(); validator.validate(this); } //-- void > validate() } > > > ------------------------------------------------------------------------ > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- -- Syscon Ingenieurbüro für Meß- und Datentechnik GmbH Ralf Joachim Raiffeisenstraße 11 D-72127 Kusterdingen Germany Tel. +49 7071 3690 52 Mobil: +49 173 9630135 Fax +49 7071 3690 98 Email: [EMAIL PROTECTED] Web: www.syscon-world.de ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] -------------------------------------------------

