after digging further, i discovered the problem, but the solution leads to another question (see end of post).


i had 2 classes Person and Dept defined as followed:

Person (uses UUID for the key generator)
------
id
name
dept_id

Dept
----
id
name


basically, i tried doing the following:

db.begin();
Dept dept = db.load(Dept,"1");
db.commit();
...
db.begin();
Person person = new Person();
person.setName("Joe Castor");
person.setDept(dept);
db.create(person);
db.commit();

apparently, if done this way, when i tried to save the "person" object, castor interpreted "dept" as being null for some reason, and because "dept_id" was defined as NOT NULL, it was giving the "ExecReplace: Fail to add null value in not null attribute dept_id" error.

however, when changed to the following:

db.begin();
Dept dept = db.load(Dept,"1");
Person person = new Person();
person.setName("Joe Castor");
person.setDept(dept);
db.create(person);
db.commit();

it worked.



< QUESTION >

in the first case, if Person and Dept implement the Timestampable interface for long transactions, why would the ExecReplace error still occur?


thank you.


At 02:01 03/02/01 -0500, you wrote:
the below exception occurred when i tried to perform the query:

SELECT p from prj.persistence.entity.person.castor.Person p WHERE p.dept = $1 AND p.code = $2

exception:

[junit] org.exolab.castor.jdo.TransactionAbortedException: Nested error: org.exolab.castor.jdo.PersistenceException: Nested error: java.sql.SQLException: ERROR: ExecReplace: Fail to add null value in not null attribute dept_id

notes:

-Person.dept is mapped to "dept_id" in the Person table.
-the values stored in dept_id are not null, but there are other columns in the Person table that are null
and are allowed to be null (i.e. column was *not* defined as NOT NULL).

using:

-castor0.9.4.2
-pg73jdbc3.jar
-jdk1.4.1_01


any ideas what might be causing this?
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev

Reply via email to