Uwe, please see inline ...
Werner On Mon, 29 Mar 2004 22:06:35 +0200, Uwe Barthel wrote: > >Hi list, > >I've followed problem and I hope anyone can help: > >I've 2 tables. One of them is a 'constants' table: > >table: person_states >+-------------+------------------+-------------+ >| PersonState | ShortDescription | Description | >+-------------+------------------+-------------+ >| 1 | VALID | valid | >| 2 | DELETED | deleted | >+-------------+------------------+-------------+ > >with mapping: >-----8<----------8<----------8<----- > <class >name="de.vidsoft.bos.struts.service.impl.BOSPersonStateCastorJDO" > identity="id" key-generator="IDENTITY" access="shared" > > <description>BOS person states for internal use</description> > <cache-type type="count-limited" capacity="2"/> > <map-to table="person_states" /> > <field name="id" type="integer" > > <sql name="PersonState" type="integer" /> > </field> > <field name="ShortDescription" type="string" > > <sql name="ShortDescription" type="varchar" /> > </field> > <field name="Description" type="string" > > <sql name="Description" type="varchar" /> > </field> > </class> >-----8<----------8<----------8<----- > > >and a table: persons >+-------------+-------------+-----------+----------+ >| BosPersonID | PersonState | FirstName | LastName | >+-------------+-------------+-----------+----------+ >| 1 | 1 | Test1 | Test1 | >| 2 | 2 | test2 | Test2 | >+-------------+-------------+-----------+----------+ > >with mapping: >-----8<----------8<----------8<----- > <class name="de.vidsoft.bos.struts.service.impl.BOSPersonCastorJDO" > identity="BosPersonID" key-generator="IDENTITY"> > <description>Person records</description> > <cache-type type="unlimited" /> > <map-to table="persons" /> > <field name="BosPersonID" type="integer" > > <sql name="BosPersonID" type="integer" /> > </field> > <field name="BosPersonState" > >type="de.vidsoft.bos.struts.service.impl.BOSPersonStateCastorJDO" > lazy="true" > > <sql name="PersonState" /> > </field> > <field name="FirstName" type="string" > > <sql name="FirstName" type="varchar" /> > </field> > <field name="LastName" type="string" > > <sql name="LastName" type="varchar" /> > </field> > </class> >-----8<----------8<----------8<----- > >The first table will be read within application startup and the entries >stored within an ArrayList. Assuming that PersonState instances do not change for the life time of the application, why don't you alter the mapping entry for PersonState so that Castor know that instances of PersonState will be read only, but never persisted (whether updated or created). Imho, if you changed the access attribute for PersonState from access="shared" to access="readonly", you'll see various benefits, one of them being that Castor will not check against the database whether the underlying object has been altered. This way, with the access attribute set to "readonly", you could simply avoid having to use an ArrayList, as you are using a Cache already (of type count-limited with a capacity of 2). > >If I create a new Person object, I set the PersonState with an Entry of >the ArrayList. Just simplify this to loading the correct instance of PersonState using Database.load(). You won't be incurring any cost related to database access, as you are using a cahce, and with read-only access mode, there won't be much of an overhead during commit phase as briefly described above. >I validate the PersonState objects an they are the same. >If now I call db.create( Person object ) within the database a new >PersonState entry and a new Person entry will be create. This could be a result of you using an IdentityKeyGenerator with PersonState, but I am not sure. Do you have a concrete requirement as to why you are using an IdentityKeyGenerator with PersonState ? I mean, this is a domain table where entries do not change during life-time of your application. >But I don't want a new PersonState entry; I need the primary key of the >PersonState within the tablerow PersonState of the new created Person >entry. Before addressing this question, I'd like to see an answer to above questions. In addition, can you please post a code fragment that shows how you are creating a Person instance and setting the PersonState property. > >I've after the create transaction: > >table: person_states >+-------------+------------------+-------------+ >| PersonState | ShortDescription | Description | >+-------------+------------------+-------------+ >| 1 | VALID | valid | >| 2 | DELETED | deleted | >| 3 | VALID | valid | >+-------------+------------------+-------------+ >table: persons >+-------------+-------------+-----------+----------+ >| BosPersonID | PersonState | FirstName | LastName | >+-------------+-------------+-----------+----------+ >| 1 | 1 | Test1 | Test1 | >| 2 | 2 | test2 | Test2 | >| 3 | 3 | test3 | Test3 | >+-------------+-------------+-----------+----------+ > >I need after the create transaction: > >table: person_states >+-------------+------------------+-------------+ >| PersonState | ShortDescription | Description | >+-------------+------------------+-------------+ >| 1 | VALID | valid | >| 2 | DELETED | deleted | >+-------------+------------------+-------------+ >table: persons >+-------------+-------------+-----------+----------+ >| BosPersonID | PersonState | FirstName | LastName | >+-------------+-------------+-----------+----------+ >| 1 | 1 | Test1 | Test1 | >| 2 | 2 | test2 | Test2 | >| 3 | ->1<- | test3 | Test3 | >+-------------+-------------+-----------+----------+ > >What I'm doing wrong ? > >The PersonState object implements Timestampable for long transactions. And finally, why is this, iima ? I thought PersonState instances are immutable, iow read-only. WHy do you want them to be TimeStampable ? >P.S.: Sorry for my bad english. No problem at all. About six years I had the same fears ... ;-). After having lived in the UK for more than five years, I came to realize that it simply does not matter whether you get everything right, as long as you manage to convey the message. > >mit freundlichen Gr��en / Kindest regards Kurze private Frage: was macht ihr mit einem Produkt wie Castor ? Oder allgemeiner, in was f�r einem software environment arbeitet ihr ? J2EE ? EJBs ? Reines Interesse .... >-- > Uwe Barthel ......... [EMAIL PROTECTED] ....... Tel: +49-351-4353400 > VidSoft GmbH ........ http://www.vidsoft.de .... Fax: +49-351-4353428 > seeing is believing . arena.vidconference.de .->.. [EMAIL PROTECTED] > GnuPG KeyID: 3DD904E7 ............................................... > Fingerprint: 74C3 B1E1 422F 8EEF FB70 BC0F B8FA BB46 3DD9 04E7 ..... > ********************************************************************* > This e-mail is intended only for the addressee named above. > As this e-mail may contain confidential or privileged information, > if you are not the named addressee, you are not authorised to > retain, read, copy or disseminate this message or any part of it. > ********************************************************************* > >----------------------------------------------------------- >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
