Barnhill William wrote:

You welcome by all means.
I've gotten to the point of
Caused by: java.sql.SQLException:
Wrong data type in statement
[insert into users (user_name, user_description, registration_date) VALUES ('dummy','A dummy user','000000f94218f84e78')]

You need to use java.sql.Timestamp as the type for the property of the bean. Database to Java type mapping is done by the JDBC driver. Cornerstone is not involved in that. There are some differences between JDBC drivers. For example, Oracle maps INT to BigDecimal while Hsqldb maps it to Integer.


Looks like it's because I'm trying to store a java.util.Date into an SQL Date and it can't handle it. Is this correct?

I could get around it by storing datestamp as string or ticks as long int, but I'd rather store it as a SQL Date. Have you or anyone else done this?

Btw, I will write a tutorial titled "Prevailing with Cornerstone persistence" that walks someone through
1. Setup of HSQL db
2. Setup of .reg files
3. Creating project dir structure
4. Where to put your interface files and naming conventions
5. Creating your classes
6. Creating a demo app that if supplied arguments created a new object with those props, otherwise dumps objects
once I am done

Wonderful! Thanks again! Refer to cornerstone-demo/hsqldb/data/*.{sql,bat} for how we set up Hsqldb and query it.


Bill

Jun



Jun Yang wrote:


Yes, Bill, your discovery is all correct. I am very sorry that you have to a detective to use it right now :). We just haven't had the time to document it much yet. I hope you (or anybody interested) can help with that too :). Thanks for your effort!

Jun

Barnhill William wrote:

More on this..
Your class that you are trying to persist must follow std JavaBeans practice of a null-arg constructor and a query.insert config property must be present.



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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to