I have an object ContactInfo which i am unable to get to accurately
persist via Castor JDO or accurately marshal into xml.
When I create a new ContactInfo object, populate the fields and
either create in the database, or marshal to xml, all the fields except
the "id" field--which is generated by a key-generator--are empty in
the db or non-existent in the xml. (see below for code/mapping/etc)
for example, db:
select * from contactinfo where contactid = 12345;
contactid|donorid|organization|phone|address1|address2|city|state|zip|country
12345|||||||||
xml:
<contact-info>
<id>12345</id>
</contact-info>
strangely, when i don't populate a field in the object, it will accurately
appear as empty:
<contact-info>
<id>12345</id>
<organization></organization>
<phone></phone>
<address2></address2>
</contact-info>
i have tried this in castor1.0M, and now updated to 1.2 and the same
problem exists. below is all the relevant mapping, code and database
information. i am using postgres 8.1.10
i don't have this problem with any other objects in my Mapping/DB.
i am at a total loss. any help would be much appreciated, even if it
is just a pointer to other debug output to look into for more information.
thanks, and see below for all mapping.code/etc,
-peter
here is the class mapping:
------------------
<key-generator name="SEQUENCE" alias="CONTACTSEQ">
<param name="sequence" value="contactinfo_contactid_seq"/>
</key-generator>
<class name="org.justgive.model.ContactInfo" identity="id"
key-generator="CONTACTSEQ">
<map-to table="contactinfo" xml="contact-info" />
<cache-type type="unlimited"/>
<field name="id" type="integer" >
<sql name="contactid" type="integer"/>
<bind-xml name="id" node="element"/>
</field>
<field name="organization" type="string" >
<sql name="organization" type="varchar"/>
<bind-xml name="organization" node="element"/>
</field>
<field name="phone" type="string" >
<sql name="phone" type="varchar"/>
<bind-xml name="phone" node="element"/>
</field>
<field name="address1" type="string" >
<sql name="address1" type="varchar"/>
<bind-xml name="address1" node="element"/>
</field>
<field name="address2" type="string" >
<sql name="address2" type="varchar"/>
<bind-xml name="address2" node="element"/>
</field>
<field name="city" type="string" >
<sql name="city" type="varchar"/>
<bind-xml name="city" node="element"/>
</field>
<field name="state" type="string" >
<sql name="state" type="varchar"/>
<bind-xml name="state" node="element"/>
</field>
<field name="zip" type="string" >
<sql name="zip" type="varchar"/>
<bind-xml name="zip" node="element"/>
</field>
<field name="country" type="string" >
<sql name="country" type="varchar"/>
<bind-xml name="country" node="element"/>
</field>
</class>
----------------------
Here is the database table:
Table contactinfo
Column : Type
contactid : serial
organization : varchar
phone : varchar
address1 : varchar
address2 : varchar
city : varchar
state : varchar
zip : varchar
country : varchar
Here is the class:
----------------------
public class ContactInfo
{
private Integer id;
private String organization;
private String phone;
private String address1;
private String address2;
private String city;
private String state;
private String zip;
private String country;
public ContactInfo(){}
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id = id;
}
public String getOrganization()
{
return organization;
}
public void setOrganization(String organization)
{
this.organization = organization;
}
public String getPhone()
{
return phone;
}
public void setPhone(String phone)
{
this.phone = phone;
}
public String getAddress1()
{
return address1;
}
public void setAddress1(String address1)
{
this.address1 = address1;
}
public String getAddress2()
{
return address2;
}
public void setAddress2(String address2)
{
this.address2 = address2;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
public String getState()
{
return state;
}
public void setState(String state)
{
this.state = state;
}
public String getZip()
{
return zip;
}
public void setZip(String zip)
{
this.zip = zip;
}
public String getCountry()
{
return country;
}
public void setCountry(String country)
{
this.country = country;
}
}
------------------
Here is the create command:
try
{
db.begin();
ContactInfo info = new ContactInfo();
info.setOrganization("organization");
info.setPhone("phone");
info.setAddress1("address1");
info.setAddress2("address2");
info.setCity("city");
info.setState("state");
info.setZip("zip");
info.setCountry("country");
db.create(info);
db.commit();
db.close();
}
catch (Exception e)
{
out(e);
}
------------------------
Here is the debug output:
-----------------------
org.castor.jdo.engine.DatabaseRegistry : DEBUG - Fetching
ConnectionFactory: jg_peter
org.exolab.castor.jdo.engine.LocalDatabaseImpl : DEBUG - Beginning tx
- TRACE: org.justgive.model.ContactInfo: Organization: organization
- TRACE: org.justgive.model.ContactInfo: Phone: phone
- TRACE: org.justgive.model.ContactInfo: Address1: address1
- TRACE: org.justgive.model.ContactInfo: Address2: address2
- TRACE: org.justgive.model.ContactInfo: City: city
- TRACE: org.justgive.model.ContactInfo: State: state
- TRACE: org.justgive.model.ContactInfo: Zip: zip
- TRACE: org.justgive.model.ContactInfo: Country: country
- TRACE: org.justgive.model.AbstractDatabaseItem: deserializing class
org.justgive.model.ContactInfo
org.exolab.castor.xml.Marshaller : DEBUG - Marshalling
org.justgive.model.ContactInfo
- TRACE: org.justgive.actions.basket.EditAccount: <?xml version="1.0"
encoding="UTF-8"?>
<contact-info/>
org.exolab.castor.persist.LockEngine : DEBUG - Creating class:
org.justgive.model.ContactInfo with id: null
org.castor.cache.DebuggingCacheProxy : DEBUG -
unlimited.remove(org.justgive.model.ContactInfo/<new>)
[org.justgive.model.ContactInfo]
org.exolab.castor.jdo.keygen.SequenceKeyGenerator : DEBUG - JDBC query
returned value 162041 from column nextval/-5
org.exolab.castor.jdo.keygen.SequenceKeyGenerator : DEBUG - Returning
value 162041 of type java.lang.Integer as key.
org.exolab.castor.jdo.engine.SQLStatementCreate : DEBUG - Creating
class: org.justgive.model.ContactInfo using SQL: Pooled statement
wrapping physical statement INSERT INTO "contactinfo"
("contactid","organization","phone","address1","address2","city","state","zip","country")
VALUES (?,?,?,?,?,?,?,?,?)
org.exolab.castor.jdo.engine.SQLStatementCreate : DEBUG - Creating
class: org.justgive.model.ContactInfo using SQL: Pooled statement
wrapping physical statement INSERT INTO "contactinfo"
("contactid","organization","phone","address1","address2","city","state","zip","country")
VALUES (162041,?,?,?,?,?,?,?,?)
org.exolab.castor.jdo.engine.SQLStatementCreate : DEBUG - Creating
class: org.justgive.model.ContactInfo using SQL: Pooled statement
wrapping physical statement INSERT INTO "contactinfo"
("contactid","organization","phone","address1","address2","city","state","zip","country")
VALUES (162041,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
org.exolab.castor.jdo.engine.SQLStatementCreate : DEBUG - Creating
class: org.justgive.model.ContactInfo using SQL: Pooled statement
wrapping physical statement INSERT INTO "contactinfo"
("contactid","organization","phone","address1","address2","city","state","zip","country")
VALUES (162041,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
org.exolab.castor.jdo.engine.LocalDatabaseImpl : DEBUG - Committing tx
org.exolab.castor.persist.ObjectLock : DEBUG - Release
org.justgive.model.ContactInfo/<162041(162041)>/36 -/W by
[EMAIL PROTECTED]
org.castor.cache.DebuggingCacheProxy : DEBUG -
unlimited.put(org.justgive.model.ContactInfo/<162041(162041)>,
[EMAIL PROTECTED]) [org.justgive.model.ContactInfo]
- DEBUG: org.justgive.actions.basket.EditAccount: ContactInfo (162041)
sdded to Donor (162208) - [EMAIL PROTECTED]
- TRACE: org.justgive.model.ContactInfo: Organization: organization
- TRACE: org.justgive.model.ContactInfo: Phone: phone
- TRACE: org.justgive.model.ContactInfo: Address1: address1
- TRACE: org.justgive.model.ContactInfo: Address2: address2
- TRACE: org.justgive.model.ContactInfo: City: city
- TRACE: org.justgive.model.ContactInfo: State: state
- TRACE: org.justgive.model.ContactInfo: Zip: zip
- TRACE: org.justgive.model.ContactInfo: Country: country
- TRACE: org.justgive.model.AbstractDatabaseItem: deserializing class
org.justgive.model.ContactInfo
org.exolab.castor.xml.Marshaller : DEBUG - Marshalling
org.justgive.model.ContactInfo
- TRACE: org.justgive.actions.basket.EditAccount: <?xml version="1.0"
encoding="UTF-8"?>
<contact-info>
<id>162041</id>
</contact-info>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email