portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jun Yang <juny...@cisco.com>
Subject Re: [J2] BasePersistentObjectFactory createInstance behavior
Date Thu, 04 Dec 2003 16:08:08 GMT
Yes, Bill, this is exactly the behavior of BasePersistentObjectFactory:

- createInstance(id) retrieves an object from database
- createInstance() creates a fresh instance (with null id property)
- store(object) stores it (does insert if id is null or update otherwise)

Jun

Barnhill William wrote:

>
> I'm trying to both wrap my head around Cornerstone and fill a need by 
> creating an Open Source voting application and a portlet to go with 
> it. I've set up my database and a simple test app based on 
> DemoPersistence.java.  The db has no users and I tried to 
> createInstance(new Integer(101)), thinking it would create a new 
> record in the db.  Apparently retrieveAndPopulate, which 
> createInstance calls, just returns null if the query returns and empty 
> recordset.  After doing walkabout in the code I discovered the 
> following inheritance tree:
> BasePersistentObjectFactory
>    which extends BasePersistenceFactory  (implements 
> IPersistenceFactory),
>        which extends InversionOfControlFactory,
>             which extends BaseFactory
>
> Seeing that store(Object) in BasePersistentObjectFactory first calls 
> createInstance(), I tracked createInstance() to the IoC factory.
> To make a long story short, and sum up the behavior:
> a. createInstance(param) - retreives the instance data from the database
> b. createInstance() - creates a fresh new instance
> c.  inst = createInstance(), set properties, store(inst) create a 
> fresh new instance and stores it in the db
>
> This may be old hat for many folks, but for anyone trying to get a 
> handle on creating their own persistent object this may be useful.
>
> Bill Barnhill 



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message