Hi,
I just cannot remember whether anybody already followed up with
questions and/or a solution to your problem ?
Regards
Werner
Stromblad wrote:
> Hi,
>
> I'm getting this error when trying to persist an object:
> org.exolab.castor.jdo.engine.SQLEngine create
> INFO: A fatal error occurred while creating/updating
> newClasses.Lom_Relation_Resource_Description_Langstring using SQL:
> INSERT INTO LOM_RELATION_RESOURCE_DESCRIPTION_LANGSTRING
> (lomRelResDesLanID,lang,content,lomRelResDesID) VALUES (?,?,?,?)
> java.sql.SQLException: Column 'lomRelResDesID' cannot be null
>
> This is the code:
> (...)
> db.begin();
> String lang = "es";
> newClasses.Lom_Relation_Resource_Description description = new
> newClasses.Lom_Relation_Resource_Description();
> newClasses.Lom_Relation_Resource_Description_Langstring
> descriptionLangstring = new
> newClasses.Lom_Relation_Resource_Description_Langstring();
> descriptionLangstring.setLang(lang);
> descriptionLangstring.setContent("langstring en espaƱol");
> description.addLangstring(descriptionLangstring);
> db.create(description);
> (...)
>
> I'm using Castor 0.9.9.1 <http://0.9.9.1> and MySQL 5.0.
>
> Any help would be appreciated,
> Thanks,
> Carmen
>
> -----------
> These are the create table statements for
> Lom_Relation_Resource_Description and
> newClasses.Lom_Relation_Resource_Description_Langstring. The relation
> between Lom_Relation_Resource_Description and
> newClasses.Lom_Relation_Resource_Description_Langstring is a 1:M relation.
>
> create table LOM_RELATION_RESOURCE_DESCRIPTION(
> lomRelResDesID integer not null
> );
>
> create table LOM_RELATION_RESOURCE_DESCRIPTION_LANGSTRING(
> lomRelResDesLanID integer not null,
> lomRelResDesID integer not null,
> content varchar(50),
> lang varchar(50)
> );
> -----------
> These are the Lom_Relation_Resource_Description and
> Lom_Relation_Resource_Description_Langstring classes:
> ...
> Lom_Relation_Resource_Description.java:
> ...
> package newClasses;
>
> public class Lom_Relation_Resource_Description extends generado.Description{
>
> private Integer _id;
>
> public Lom_Relation_Resource_Description() {
> }
>
> public void setId(Integer id){
> this._id = id;
> }
>
> public Integer getId(){
> return this._id;
> }
>
> public void
> addLangstring(newClasses.Lom_Relation_Resource_Description_Langstring
> vLangstring)
> throws java.lang.IndexOutOfBoundsException
> {
> _langstringList.addElement(vLangstring);
> }
>
> public void addLangstring(int index,
> newClasses.Lom_Relation_Resource_Description_Langstring vLangstring)
> throws java.lang.IndexOutOfBoundsException
> {
> _langstringList.insertElementAt(vLangstring, index);
> }
>
> public newClasses.Lom_Relation_Resource_Description_Langstring
> getLangstring(int index)
> throws java.lang.IndexOutOfBoundsException
> {
> //-- check bounds for index
> if ((index < 0) || (index > _langstringList.size())) {
> throw new IndexOutOfBoundsException("getLangstring: Index
> value '"+index+"' not in range [0.."+_langstringList.size()+ "]");
> }
>
> return (newClasses.Lom_Relation_Resource_Description_Langstring)
> _langstringList.elementAt(index);
> }
>
> public newClasses.Lom_Relation_Resource_Description_Langstring[]
> getLangstring()
> {
> int size = _langstringList.size();
> newClasses.Lom_Relation_Resource_Description_Langstring[] mArray
> = new newClasses.Lom_Relation_Resource_Description_Langstring[size];
> for (int index = 0; index < size; index++) {
> mArray[index] =
> (newClasses.Lom_Relation_Resource_Description_Langstring)
> _langstringList.elementAt(index);
> }
> return mArray;
> }
>
> }
> ...
> The only important thing about generado.Description.java is that it has
> an attribute like this:
> protected java.util.Vector _langstringList;
> ...
> Lom_Relation_Resource_Description_Langstring
> ...
> package newClasses;
>
> public class Lom_Relation_Resource_Description_Langstring extends
> generado.Langstring{
> private Integer _id;
> private newClasses.Lom_Relation_Resource_Description
> _lomRelationResourceDescription;
>
> public Lom_Relation_Resource_Description_Langstring() {
> }
>
> public void setId(Integer id){
> this._id = id;
> }
>
> public Integer getId(){
> return this._id;
> }
>
> public void
> setLomRelationResourceDescription(newClasses.Lom_Relation_Resource_Description
> description){
> this._lomRelationResourceDescription = description;
> }
>
> public newClasses.Lom_Relation_Resource_Description
> getLomRelationResourceDescription(){
> return this._lomRelationResourceDescription;
> }
> }
> ...
> generado.Langstring has these two attributes:
> private java.lang.String _content = "";
> private java.lang.Object _lang;
> ...
> -------------
> mapping.xml
> ...
> <class name=" newClasses.Lom_Relation_Resource_Description"
> identity="_id" key-generator="MAX">
> <map-to xml="description"
> table="LOM_RELATION_RESOURCE_DESCRIPTION"/>
> <field name="_id" type="integer" get-method="getId"
> set-method="setId">
> <sql name="lomRelResDesID"/>
> </field>
> <field name=" _langstringList"
> type="newClasses.Lom_Relation_Resource_Description_Langstring"
> collection="array" get-method="getLangstring"
> set-method="setLangstring" required="true">
> <sql many-key="lomRelResDesID"/>
> <bind-xml name="langstring"/>
> </field>
> </class>
> ...
> <class name="newClasses.Lom_Relation_Resource_Description_Langstring
> " identity="_id" key-generator="MAX"
> depends="newClasses.Lom_Relation_Resource_Description">
> <map-to xml="langstring"
> table="LOM_RELATION_RESOURCE_DESCRIPTION_LANGSTRING"/>
> <field name="_id" type="integer" get-method="getId"
> set-method="setId">
> <sql name="lomRelResDesLanID"/>
> </field>
> <field name="_lang" type="other" get-method="getLang"
> set-method="setLang">
> <sql name="lang"/>
> <bind-xml name="xml:lang" node="attribute"/>
> </field> <field name="content" type="string">
> <sql name="content"/>
> <bind-xml node="text"/>
> </field>
> <field name="_lomRelationResourceDescription"
> type="newClasses.Lom_Relation_Resource_Description"
> get-method="getLomRelationResourceDescription"
> set-method="setLomRelationResourceDescription">
> <sql name="lomRelResDesID"/>
> </field>
> </class>
> ...
>
>
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------