Hi everyone,
I need to do some CRUDs for a number of tables that do not have
auto-generated keys, that is, the primary key is an input field of the form.
I am using Appfuse 2.0.1 with JSF and iBATIS and would like to use the class
GenericDaoiBatis without overriding. 
This implementation though, in the save method, takes the decision for
insert or update in the following way:
        // check for new record
        if (StringUtils.isBlank(keyId)) {
            ... insert ...
        } else {
            ... update ...
        }
and therefore, in my case, goes always for update (keyId is always set).

In order to avoid overriding the GenericDAO, I see a couple of solutions:
1) put in the BaseObject a boolean attribute (e.g. new) to be set by the
form + modify GenericDaoiBatis to use this attribute
2) modify the GenericDaoiBatis making it try to first read the record in
order to decide for insert or update

Does anyone has a better solution? I really would avoid making changes to
Appfuse code.

Thanks 

Vincenzo Caselli

-- 
View this message in context: 
http://www.nabble.com/CRUD-with-Non-autogenerated-primary-keys-tp16822105s2369p16822105.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to