I think you are going to have to modify the appfuse iBatis code to do
what you want. In your position I would refactor the save() method
and extract the insert and update up to the interface so you can call
them directly if you want. You can leave save() and have it call
update or insert based on the original "id" logic, but you can call
insert or update based on whatever logic you want in your web
actions. Since rest is so hot these days, it is fashionable to split
your new/create and edit/update web methods anyways, so its easy to
know which one to call if your set up that way.
-D
On Apr 21, 2008, at 10:46 PM, Cens wrote:
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]