Should I create a bugzilla bug to track the resolution
of this issue?
--- Jon Wilmoth <[EMAIL PROTECTED]> wrote:
>
> 1) Before creating a BookContract instance, how have
> you loaded the other entities? Using Database,
> load()
> I assume. And when you are about to create the
> BookContract instance?
>
> In order to populate the drop-downs of Books,
> Authors,
> and Publishers, I do use Database.load, but the
> objects become transient (in the Castor sense) as
> Database.commit() is called after querying the DB.
> The Struts form that wraps the BookContract
> initializes new/empty instances of Book, Author, and
> Publisher (i.e. bookContract.setPublisher(new
> Publisher()) ) if the fields are null (as is the
> case
> for a new BookContract) so the reflection mechanism
> struts uses to populate the bean properties work.
> Thus struts is populating the BookContract and it's
> complex fields all while they are transient. I then
> use Database.create() on that transient object.
> Because the complex fields in the BookContract are
> not
> persisent the ClassMolder.getIdentity method returns
> null even through the transient field has a not-null
> identity.
>
>
> 2) Is there a particular reason why you are using
> capacity "0" here ?
>
> I've been using castor for almost 2 yrs and at some
> point I was having caching issues with my usage. I
> honestly don't recall the particulars, but I will
> most
> likely revisit how I generate the cache mapping
> values. First I have to get C.R.U.D. functionality
> working ;)
>
> 3) Specifying lazy="true" in this context will
> (unfortunately) not bring the desired results. At
> the
> moment, lazy loading works with collections only.
>
> I am aware of this as I have seen the warning log
> messages (very helpful!). I figured since it
> doesn't
> cause any problems with my current usage, I'd leave
> my
> current xsl stylesheet that generates the mappings
> alone for now.
>
> --- Werner Guttmann <[EMAIL PROTECTED]> wrote:
> >
> > Jon,
> >
> > please see below ...
> >
> > Werner
> >
> > On Tue, 18 May 2004 20:10:21 -0700 (PDT), Jon
> > Wilmoth wrote:
> >
> > >
> > >I'm using a number of long transactions in a
> > webapp,
> > >so I'll abreviate the sequence of events. The
> > classes
> > >& mapping involved are below.
> > >
> > >The basic premise is the user selects a Book,
> > Author,
> > >and Publisher from dropdowns (dropdowns contain
> id
> > >property of each existing object).
> > >
> > >Now the flow involving castor...
> > >1) Struts populates BookContract.book.id,
> > >BookContract.author.id and
> > BookContract.publisher.id
> > >values. Logging in the setters shows this is
> > >happening without error.
> > >2) Struts action calls BookContract.save().
> > Logging
> > >in this method shows all required fields have
> > values.
> > >3) ClassMolder getIdentity returns null for
> > >BookContract.book, BookContract.author,
> > >BookContract.publisher field values.
> >
> > Before creating a BookContract instance, how have
> > you loaded the other entities ? Using
> > Database,load() I assume. And when you are about
> to
> > create
> > the BookContract instance,
> >
> > >Logging in the
> > >ClassMolder.create method shows BookContract with
> > >author, publisher, and book fields all with
> > non-null
> > >id properties.
> > >4) SQLEngine executes prepared statement with
> nulls
> > >bound to the A1_BOOK_CONTRACT.BOOK_ID,
> > >A1_BOOK_CONTRACT.AUTHOR_ID, and
> > >A1_BOOK_CONTRACT.PUBLISHER_ID columns which have
> db
> > >not null constraints.
> > >
> > >
> > >
> > >package castor.sample;
> > >
> > >public abstract class CastorClass implements
> > >Persistent, TimeStampable, Serializable {
> > > public void save() {
> > > //...
> > > Database db = getDatabase();
> > > if (getId() == null) {
> > > log.debug(">>> Insert <<<");
> > > db.create(this);
> > > } else {
> > > log.debug(">>> Update " + getId() +
> > >"<<<");
> > > db.update(this);
> > > }
> > > //..
> > > }
> > >}
> > >
> > >package castor.sample;
> > >
> > >public class Author extends CastorClass {
> > >
> > > protected Long id;
> > > protected String firstName;
> > > protected String lastName;
> > > //Marked as transient because the castor
> > persistent
> > >collection is not serializeable
> > > protected transient Collection bookContracts =
> new
> > >ArrayList();
> > >
> > > //getters & setters ...
> > >}
> > >
> > ><class name="castor.sample.Author"
> > >key-generator="Author_SEQUENCE"
> > >verify-constructable="true" auto-complete="true"
> > >identity="id">
> > > <cache-type type="unlimited" capacity="0"/>
> >
> > Is there a particular reason why you are using
> > capacity "0" here ?
> >
> > > <map-to table="A1_AUTHOR"/>
> > > <field name="id" type="long">
> > > <sql name="ID" type="bigint"/>
> > > </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="bookContracts"
> > >type="castor.sample.BookContract" required="true"
> > >lazy="true" collection="collection">
> > > <sql many-key="AUTHOR_ID"/>
> > > </field>
> > ></class>
> > ><key-generator name="IDENTITY"
> > >alias="Author_SEQUENCE"/>
> > >
> > >---------------------------
> > >
> > >package castor.sample;
> > >
> > >public class Book extends CastorClass {
> > >
> > > protected Long id;
> > > protected String name;
> > > //Marked as transient because the castor
> > persistent
> > >collection is not serializeable
> > > protected transient Collection bookContracts =
> new
> > >ArrayList();
> > >
> > > //getters & setters ...
> > >}
> > >
> > ><class name="castor.sample.Book"
> > >key-generator="Book_SEQUENCE"
> > >verify-constructable="true" auto-complete="true"
> > >identity="id">
> > > <cache-type type="unlimited" capacity="0"/>
> > > <map-to table="A1_BOOK"/>
> > > <field name="id" type="long">
> > > <sql name="ID" type="bigint"/>
> > > </field>
> > > <field name="name" type="string">
> > > <sql name="NAME" type="char"/>
> > > </field>
> > > <field name="bookContracts"
> > >type="castor.sample.BookContract" required="true"
> > >lazy="true" collection="collection">
> > > <sql many-key="BOOK_ID"/>
> > > </field>
> > ></class>
> > ><key-generator name="IDENTITY"
> > alias="Book_SEQUENCE"/>
> > >
> > >package castor.sample;
> > >public class BookContract extends CastorClass {
> > >
> > > protected Long id;
> > > protected castor.sample.Book book;
> > > protected castor.sample.Author author;
> > > protected castor.sample.Publisher publisher;
> > >
> > > //getters & setters ...
> > >}
> > >
> > ><class name="castor.sample.BookContract"
> > >key-generator="BookContract_SEQUENCE"
> > >verify-constructable="true" auto-complete="true"
> > >identity="id">
> > > <cache-type type="unlimited" capacity="0"/>
> > > <map-to table="A1_BOOK_CONTRACT"/>
> > > <field name="id" type="long">
> > > <sql name="ID" type="bigint"/>
> > > </field>
> > > <field name="book" type="castor.sample.Book"
> > >lazy="true">
> > Specifying lazy="true" in this context will
> > (unfortunately) not bring the desired results. At
> > the moment, lazy loading works with collections
> > only.
> >
> > > <sql name="BOOK_ID"/>
> > > </field>
> > > <field name="author" type="castor.sample.Author"
> > >lazy="true">
> > > <sql name="AUTHOR_ID"/>
> > > </field>
> > > <field name="publisher"
> > >type="castor.sample.Publisher" lazy="true">
> > > <sql name="PUBLISHER_ID"/>
> > > </field>
> > ></class>
> > ><key-generator name="IDENTITY"
> > >alias="BookContract_SEQUENCE"/>
> > >
> > >package castor.sample;
> > >public class Publisher extends CastorClass {
> > >
> > > protected Long id;
> > > protected String name;
> > > //Marked as transient because the castor
> > persistent
> > >collection is not serializeable
> > > protected transient Collection bookContracts =
> new
> > >ArrayList();
> > >
> > > //getters & setters ...
> > >}
> > >
> > ><class name="castor.sample.Publisher"
> > >key-generator="Publisher_SEQUENCE"
> > >verify-constructable="true" auto-complete="true"
> > >identity="id">
> > > <cache-type type="unlimited" capacity="0"/>
> > > <map-to table="A1_PUBLISHER"/>
> > > <field name="id" type="long">
> > > <sql name="ID" type="bigint"/>
> > > </field>
> > > <field name="name" type="string">
> > > <sql name="NAME" type="char"/>
> > > </field>
> > > <field name="bookContracts"
> > >type="castor.sample.BookContract" required="true"
> > >lazy="true" collection="collection">
> > > <sql many-key="PUBLISHER_ID"/>
> > > </field>
> > ></class>
> > ><key-generator name="IDENTITY"
> > >alias="Publisher_SEQUENCE"/>
> > >
> > >
> > >--- Werner Guttmann <[EMAIL PROTECTED]>
> > wrote:
> > >>
> > >> Jon,
> > >>
> > >> for us to be able to help you with your
> problem,
> > can
> > >> you please post the relevant parts of your
> > mapping
> > >> file, entities, code and JDO config file ?
> > >>
> > >> Thanks
> > >> Werner
> > >>
> > >> On Tue, 18 May 2004 13:06:01 -0700 (PDT), Jon
> > >> Wilmoth wrote:
> > >>
> > >> >
> > >> >I have a one-to-many relationship and am
> getting
> > a
> > >> >database not null constraint violation trying
> to
> > >> save
> > >> >a child object that has as one of it's fields
> a
> > >> castor
> > >> >mapped object...the parent object. I've
> tracked
> > >> the
> > >> >problem down to the getIdentity(
> > TransactionContext
> > >> >tx, Object o ) method in the ClassMolder.
> While
> > >> >processing the child object's parent object
> > field
> > >> it's
> > >> >returning null for the parent object's id
> > because
> > >> of
> > >> >the following statement:
> > >> >
> > >> >if ( isKeyGeneratorUsed() && !
> > (tx.isPersistent(o)
> > >> ||
> > >> >tx.isReadOnly(o)))
> > >> >
> > >> >since the isKeyGeneratorUsed is returning true
> > for
> > >> the
> > >> >parent object field.
> > >> >
> > >> >Is this how it's supposed to work and I'm
> simply
> > >> not
> > >> >using Castor correctly or is this a bug?
> > >> >
> > >> >
> > >> >
> > >>
> >
>
>>-----------------------------------------------------------
> > >>
> > >> >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