Are there known problems with the required="true" field for a class definition in the mapping file?

I've got the following mapping file which seems to be producing weird errors...

See below.


<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd";>
<mapping>

<class name="com.xyz.beans.Note" identity="id" key-generator="MAX">

<map-to table="notes" />

<field name="id" type="integer">
<sql name="id" type="integer" />
</field>

<field name="text" type="string">
<sql name="text" type="char" />
</field>

<field name="user" type="com.xyz.beans.User" required="true">
<sql name="user_id" />
</field>
</class>

<class name="com.xyz.beans.User" identity="id" key-generator="MAX">
<map-to table="users" />

<field name="id" type="integer">
<sql name="id" type="integer" />
</field>

<field name="firstName" type="string">
<sql name="first_name" type="char" />
</field>

<field name="lastName" type="string">
<sql name="last_name" type="char" />
</field>

<field name="userName" type="string">
<sql name="user_name" type="char" />
</field>

<field name="password" type="string">
<sql name="password" type="char" />
</field>

<field name="accessLevel" type="string">
<sql name="access_level" type="char" />
</field>

</class>

<class name="com.xyz.beans.Market" identity="id" key-generator="MAX">
<map-to table="markets" />

<field name="id" type="integer">
<sql name="id" type="integer" />
</field>

<field name="description" type="string">
<sql name="description" type="char" />
</field>

</class>

<class name="com.xyz.beans.Skill" identity="id" key-generator="MAX">
<map-to table="skills" />

<field name="id" type="integer">
<sql name="id" type="integer" />
</field>

<field name="parentId" type="integer">
<sql name="parent_id" type="integer" />
</field>

<field name="glossaryId" type="integer">
<sql name="glossary_id" type="integer" />
</field>

<field name="type" type="integer">
<sql name="type" type="integer" />
</field>

<field name="name" type="string">
<sql name="name" type="char" />
</field>

<field name="path" type="string">
<sql name="path" type="char" />
</field>

</class>

<class name="com.xyz.beans.History"
identity="id"
key-generator="MAX">

<map-to table="history" />

<field name="id" type="integer">
<sql name="id" type="integer" />
</field>

<field name="text" type="string">
<sql name="text" type="char" />
</field>

<field name="user" type="com.xyz.beans.User" required="true">
<sql name="user_id" />
</field>

</class>


<class name="com.xyz.beans.Location"
identity="id"
key-generator="MAX">

<map-to table="locations" />

<field name="id" type="integer">
<sql name="id" type="integer" />
</field>

<field name="description" type="string">
<sql name="description" type="char" />
</field>
</class>

</mapping>

When its instanciating the mappings I get this:

[XYZ] Key generator MAX has been instantiated, parameters: {}
[XYZ] SQL for creating com.xyz.beans.Note: INSERT INTO notes (id,text,user_id) VALUES (?,?,?)
[XYZ] SQL for deleting com.xyz.beans.Note: DELETE FROM notes WHERE id=?
[XYZ] SQL for updating com.xyz.beans.Note: UPDATE notes SET text=?,user_id=? WHERE id=? AND text=? AND user_id=?
[XYZ] SQL for loading com.xyz.beans.Note: SELECT notes.text,notes.user_id FROM notes WHERE notes.id=?
[XYZ] SQL for creating com.xyz.beans.User: INSERT INTO users (id,first_name,last_name,user_name,password,access_level) VALUES (?,?,?,?,?,?)
[XYZ] SQL for deleting com.xyz.beans.User: DELETE FROM users WHERE id=?
[XYZ] SQL for updating com.xyz.beans.User: UPDATE users SET first_name=?,last_name=?,user_name=?,password=?,access_level=? WHERE id=? AND first_name=? AND last_name=? AND user_name=? AND password=? AND access_level=?
[XYZ] SQL for loading com.xyz.beans.User: SELECT users.first_name,users.last_name,users.user_name,users.password,users.access_level FROM users WHERE users.id=?
[XYZ] SQL for creating com.xyz.beans.Market: INSERT INTO markets (id,description) VALUES (?,?)
[XYZ] SQL for deleting com.xyz.beans.Market: DELETE FROM markets WHERE id=?
[XYZ] SQL for updating com.xyz.beans.Market: UPDATE markets SET description=? WHERE id=? AND description=?
[XYZ] SQL for loading com.xyz.beans.Market: SELECT markets.description FROM markets WHERE markets.id=?
[XYZ] SQL for creating com.xyz.beans.Skill: INSERT INTO skills (id,parent_id,glossary_id,type,name,path) VALUES (?,?,?,?,?,?)
[XYZ] SQL for deleting com.xyz.beans.Skill: DELETE FROM skills WHERE id=?
[XYZ] SQL for updating com.xyz.beans.Skill: UPDATE skills SET parent_id=?,glossary_id=?,type=?,name=?,path=? WHERE id=? AND parent_id=? AND glossary_id=? AND type=? AND name=? AND path=?
[XYZ] SQL for loading com.xyz.beans.Skill: SELECT skills.parent_id,skills.glossary_id,skills.type,skills.name,skills.path FROM skills WHERE skills.id=?
[XYZ] SQL for creating com.xyz.beans.History: INSERT INTO history (id,text,user_id) VALUES (?,?,?)
[XYZ] SQL for deleting com.xyz.beans.History: DELETE FROM history WHERE id=?
[XYZ] SQL for updating com.xyz.beans.History: UPDATE history SET text=?,user_id=? WHERE id=? AND text=? AND user_id=?
[XYZ] SQL for loading com.xyz.beans.History: SELECT history.text,history.user_id FROM history WHERE history.id=?
[XYZ] SQL for creating com.xyz.beans.Location: INSERT INTO locations (id,description) VALUES (?,?)
[XYZ] SQL for deleting com.xyz.beans.Location: DELETE FROM locations WHERE id=?
[XYZ] SQL for updating com.xyz.beans.Location: UPDATE locations SET description=? WHERE id=? AND description=?
[XYZ] SQL for loading com.xyz.beans.Location: SELECT locations.description FROM locations WHERE locations.id=?
[XYZ] java.lang.NullPointerException

whats with the Exception at the end???

When I create an instamce on Note without calling setUser(user) it will still allow me to save it despite declaring it as required="true"

Any ideas about what I've done wrong?

Doe the order of the class declarations matter at all? I've tried it with the user class declared first but it made no difference.

Thanks,
qwam.

PS: I really want to use Castor for one of the projects I'm working on but I'm seem to be having mysterious problems with even getting the most basic stuff going.

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev

Reply via email to