Aha! I think I found the problem. The call to Database.close()
appears to cause Castor to quit tracking the state of things.

I thought that Database == JDBC database connection. But I think
I am worng. Castor appears to acquire a connection _per transaction_
and so, as long as the transaction is either committed or rolled back,
a JDBC connection leak should not happen.

Does this make sense?

--Kevin

-----Original Message-----
From: Smith, Kevin [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 4:45 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Collection dirty-checking not occuring (Castor
J DO)


Both of the classes (User and Group) implement TimeStampable.

The code to load a Castor-persisted object looks like this:

Database db = jdo.getDatabase();
db.begin();
db.setAutoStore(true);
...execute an OQL query here and get results....

db.commit();
db.close();

The code to persist an object looks like this:

Database db = jdo.getDatabase();
db.begin();
db.setAutoStore(true);
db.update(data);
db.commit();

I've left out a lot of exception handling code for clarity.

I've experimented with setAutoStore() but it seems to have no effect.

Am I doing something wrong here?

--Kevin

-----Original Message-----
From: Martin, Margaret [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 4:32 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Collection dirty-checking not occuring (Castor
J DO)


Kevin,
Can you go into more detail about how you're invoking the update and what
your classes look like (ie do they implement Timestampable?)... I'm using
the "add" capability for a dependent object with a mapping similar to what
you are describing...

Margaret



-----Original Message-----
From: Smith, Kevin [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 3:19 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Collection dirty-checking not occuring (Castor
J DO)


Margaret - 

Thanks for the idea. I tried that right after I read your reply, but the row
is still not being created :(

-----Original Message-----
From: Martin, Margaret [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 4:08 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Collection dirty-checking not occuring (Castor
J DO)


Kevin,
I think that in order to get the behaviour that you want, you'd need to add
depends="User" to your Group mapping. However, then all persistence of
groups would have to happen within the context of a User, which might not
really be the behavior that you're after.

Hope this helps...
Margaret

-----Original Message-----
From: Smith, Kevin [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 2:51 PM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Collection dirty-checking not occuring (Castor
JDO)


I'm having a problem with Castor JDO and I'm hoping that someone can shed
some light.....

I have two classes: User and Group. The JDO mapping for them looks like
this:

<class name="User" identity="userid" cache-type="unlimited"
      auto-complete="false">

   <map-to table="USERS" />

   <field name="userid" type="java.lang.String" set-method="setUserId" 
         get-method="getUserId">
      <sql name="USER_ID" type="varchar" />
   </field>

   <field name="password" type="java.lang.String" set-method="setPassword"
         get-method="getPassword">
      <sql name="PASSWORD" type="varchar" />
   </field>

   <field name="groups" type="Group" set-method="setGroups"
         get-method="getGroups" collection="collection">
      <sql many-table="USER_GROUPS" many-key="USER_ID" />
   </field>
</class>

<class name="Group" identity="id" cache-type="unlimited"
            auto-complete="false">
        <map-to table="GROUPS" />

   <field name="id" type="long" set-method="setId" get-method="getId">
      <sql name="GROUP_ID" />
   </field>

   <field name="name" type="string" set-method="setName"
get-method="getName">
      <sql name="GROUP_DESCRIPTION" />
   </field>

</class>

Castor works for instantiating a user object. The user.groups collection is
correctly populated if I pre-populate the underlying database table.
Castor seems to pick up the changes and delete rows when I remove a Group 
object from the user.groups collection. However, when I _add_ a Group object
 to the user.groups collection and subsequently save the the User object 
instance to the database via Database.update(), the new row is never
created.

I've tried change the cache-type setting and turning on/off auto update with
no effect.
Does anyone see problems with my config or the logical process for saving
changes?

Thanks,
Kevin

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

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

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

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

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

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

Reply via email to