You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Peter A. J. Pilgrim" <pe...@xenonsoft.demon.co.uk> on 2002/11/28 01:39:50 UTC

Re: FW: Persistence Framework Comparison?

  -----Original Message-----
> From: Robert J. Sanford, Jr. [mailto:rsanford@trefs.com] 
> Sent: Friday, October 04, 2002 5:59 PM
> To: Struts Users Mailing List
> Subject: RE: Persistence Framework Comparison?
> 
> 
> There are two things that I want/need in a persistence framework and I
> have yet to find them. I know that OJB does not support them and I have
> not looked very hard at the others. Maybe you can tell me if Expresso
> handles them.
> 
> 1) Read only attributes so that a setter method is not automatically
> generated for one and that value is never persisted, just read.
> 

Expresso DB Object has recognise read only fields, such PRIMARY KEYS.
and also virtual fields, concocted field that don't actually
exist in the database table, that you create in Java and derive from
calculation.

> 2) The ability to persist an object to a different "table" than it was
> read from. Yes this seems odd so let me explain in a few simple words
> followed by a simplistic example. The simple words are - performance and
> simplicity. When developing a web app database I tend to go for
> normalization. The employees are in one table with a FK to the
> department table. But, when displaying the data on a page I want to
> display the name of the department, not its database ID. So, I use a
> view that joins the two tables meaning that
>    a) I get all the data that I need in a single query I can
>       get all of the information I need for display (performance)
>       and...
>    b) I don't have to worry about reading data from multiple
>       queries and/or multiple objects (simplicity).
> 

In an ``enter new employee'' form you typically want to generate a HTML
drop list of departments, right ?
`SELECT DEPT_ID, DEPT_NAME FROM DEPARTMENTS'
So you need access to the department table.

Of course when you want to view the employee record, in Expresso you
can create Employee DBObject with valid values look up for virtual field
"department_name" for html option select. Expresso can also cache
these valid values for you as well. So you need not blast the database
with "SELECT DEPT_ID, DEPT_NAME ...." queries.

> But, I cannot guarantee that the view I am reading from is updateable so
> I have to insert/update to the simple tables (employee for instance).
> 
> So, can you help me out here? Can Expresso do this?
> 

When caching is involved, you have two choices?

1) Blow out the caches.

2) Make sure the caches are big enough store all of the data,
entire population, and only update the database using Expresso
Admin or front end that you wrote using Expresso.

This is not also an issue for Expresso but also J2EE containers.
Namely EJB CMP implementation that support cacheable data.
What will typically happen is that Sys-Admin/ Sys-DBA will use
the Oracle front end SQLPLUS or ISQL or MYSQL to go "behind the cache"
and manually modify the static data, in which case you have no chance
except to (1), but it is not like you are going to add a department
every 10 minutes or so!

-- 
Peter Pilgrim
ServerSide Java Specialist

My on-line resume and for interview videos about myself, J2EE
Open Source, Struts and Expresso.
    ||
    \\===>  `` http://www.xenonsoft.demon.co.uk/no-it-striker.html ''


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: FW: Persistence Framework Comparison?

Posted by "Peter A. J. Pilgrim" <pe...@xenonsoft.demon.co.uk>.
Peter A. J. Pilgrim wrote:
>  -----Original Message-----
> 
>> From: Robert J. Sanford, Jr. [mailto:rsanford@trefs.com] Sent: Friday, 
>> October 04, 2002 5:59 PM
>> To: Struts Users Mailing List
>> Subject: RE: Persistence Framework Comparison?
>>
>>
>> There are two things that I want/need in a persistence framework and I
>> have yet to find them. I know that OJB does not support them and I have
>> not looked very hard at the others. Maybe you can tell me if Expresso
>> handles them.
>>
>> 1) Read only attributes so that a setter method is not automatically
>> generated for one and that value is never persisted, just read.
>>

--////--


> 
>> 2) The ability to persist an object to a different "table" than it was
>> read from. Yes this seems odd so let me explain in a few simple words
>> followed by a simplistic example. The simple words are - performance and
>> simplicity. When developing a web app database I tend to go for
>> normalization. The employees are in one table with a FK to the
>> department table. But, when displaying the data on a page I want to
>> display the name of the department, not its database ID. So, I use a
>> view that joins the two tables meaning that
>>    a) I get all the data that I need in a single query I can
>>       get all of the information I need for display (performance)
>>       and...
>>    b) I don't have to worry about reading data from multiple
>>       queries and/or multiple objects (simplicity).
>>
> 
> In an ``enter new employee'' form you typically want to generate a HTML
> drop list of departments, right ?
> `SELECT DEPT_ID, DEPT_NAME FROM DEPARTMENTS'
> So you need access to the department table.
> 
> Of course when you want to view the employee record, in Expresso you
> can create Employee DBObject with valid values look up for virtual field
> "department_name" for html option select. Expresso can also cache
> these valid values for you as well. So you need not blast the database
> with "SELECT DEPT_ID, DEPT_NAME ...." queries.
> 

--////--

Here some example incomplete code that illustrates what Expresso DBObject
can do here.


package com.xenonsoft.acme.killerapp.dbobj;

...

public Employee extends SecuredDBObject
{

     public Vector getValidValues(String fieldName) throws DBException {
         if (fieldName.equals("employee_type")) {
	    // for the PAY ROLL dept
             Vector h = new Vector(6);
             h.addElement(new ValidValue("FTE", "Permanent Full/Time"));
             h.addElement(new ValidValue("PTE", "Permanent Part/Time"));
             h.addElement(new ValidValue("GII", "Graduate Intern Intake"));
             h.addElement(new ValidValue("CON", "Consultant"));
             h.addElement(new ValidValue("CCE", "Computer Contractor/Engineer"));
             return h;
         }
         return super.getValidValues(fieldName);
     }

     ...

     /**
      * Set up Meta Data (incomplete)
      */
     protected synchronized void setupFields() throws DBException {
         setTargetTable("EMPLOYEE");

         setDescription("Employee");

         addField("emp_id", "int", 0, false, "employee id");
         addField("first_name", "varchar", 48, true, "First name");
         addField("middle_names", "varchar", 64, true, "First name");
         addField("last_name", "varchar", 48, true, "Last name");
         addField("dept_id", "int", 0, false, "department id");

	// `employee_type' is a look up value
         addMultiValued("employee_type", "char", 3, true, "Employee Type");

	// Secret virtual field derive
         addVirtualField("secret_salary", "real", 0, "secret pay, the enron field");

	// Primary Key
	addKey("emp_id");

	// Department name look up in another data object.
	setLookupObject("dept_id",
			"com.xenonsoft.acme.killerapp.dbobj.Department");

     } /* setupFields() */

     ...
}


-- 
Peter Pilgrim
ServerSide Java Specialist

My on-line resume and for interview videos about myself, J2EE
Open Source, Struts and Expresso.
    ||
    \\===>  `` http://www.xenonsoft.demon.co.uk/no-it-striker.html ''


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>