Castor 0.9.3.9. The exception:
java.sql.SQLException: ERROR: ExecAppend: Fail to add null value in not
null attribute content
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
at org.postgresql.Connection.ExecSQL(Connection.java:398)
at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
at org.postgresql.jdbc2.Statement.executeUpdate(Statement.java:73)
at
org.postgresql.jdbc2.PreparedStatement.executeUpdate(PreparedStatement.java:113)
at org.exolab.castor.jdo.engine.SQLEngine.create(SQLEngine.java:616)
at org.exolab.castor.persist.ClassMolder.create(ClassMolder.java:891)
at org.exolab.castor.persist.LockEngine.create(LockEngine.java:458)
at
org.exolab.castor.persist.TransactionContext.create(TransactionContext.java:804)
at org.exolab.castor.jdo.engine.DatabaseImpl.create(DatabaseImpl.java:338)
at
com.ingenta.clownbike.DiscussionMessageFactory.create(DiscussionMessageFactory.java:40)
[etc]
The relevant lines of my code:
public DiscussionMessage create( String title ) throws Exception {
DiscussionMessageImpl discussionMessage =
new DiscussionMessageImpl ();
discussionMessage.setId( AutoNumberFactory.getNextInteger
("DiscussionMessage", _db) );
discussionMessage.setTitle( title );
_db.create( discussionMessage ); // this line generates the
// Exception
return discussionMessage;
}
The mapping file for DiscussionMessageImpl:
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
1.0//EN"
"http://Castor.exolab.org/mapping.dtd">
<mapping>
<!-- Mapping for DiscussionMessage -->
<class name="com.ingenta.clownbike.DiscussionMessageImpl"
identity="id">
<description>DiscussionMessage</description>
<map-to table="discussionMessage" xml="discussionMessage" />
<field name="id" type="integer" >
<sql name="id" type="integer"/>
<bind-xml name="id" node="attribute"/>
</field>
<field name="title" type="string">
<sql name="title" type="varchar" dirty="check" />
<bind-xml name="title" node="element" />
</field>
<field name="content" type="string">
<sql name="content" type="longvarchar" dirty="check" required="false"/>
<bind-xml name="content" node="element" />
</field>
<field name="postedDate" type="date" required="false">
<sql name="posted" type="date" dirty="check" />
<bind-xml name="start-date" node="attribute" />
</field>
</class>
</mapping>
I notice that I get this error when I don't set the
DiscussionMessageImpl's "content" or "postedDate" fields. When I do set
them, things work fine. But the fields are not required! Am I doing
something wrong?
The database is Postgresql.
j
---
"Users complain that they receive too much spam, while spammers protest
messages are legal." -InfoWorld
"You do not have to do everything disagreeable that you have a right to
do." -Judith Martin (Miss Manners)
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev