|
From: Matt G. <ma...@po...> - 2003-07-04 12:42:26
|
Hi,
If you *really* need a DTO then this is not going to help but SQLObject=20
already provides the set() method for updating multiple attributes in=20
one UPDATE statement. Consider the following code (untested):
class Person(SQLObject):
firstName =3D StringCol()
lastName =3D StringCol()
# Do an INSERT
p =3D Person.new(firstName=3D'Matt, lastName=3D'Goodall')
# UPDATE first_name
p.firstName =3D 'Francois'
# UPDATE last_name
p.lastName =3D 'Girault'
# UPDATE first_name and last_name in one go
p.set(firstName=3D'Matt, lastName=3D'Goodall')
Hope that helps.
Cheers, Matt
Fran=E7ois Girault wrote:
>Hi all,
>
>I've a new need (arg ;) ) :
>
>I've to minimize network traffic : I want to update an SQLObject (or
>better a collection) once I've modified all the attributes.
>
>I know a design pattern from j2ee/ejb : Data Transfert Object
>(www.theserverside.com provides a free book : "ejb design patterns",
>which describes DTO on page 47).=20
>
>This pattern says : a SQLObj produces a light object that doesn't update
>the db each an attribute is set. Once the work with this DTO is done, it
>would be passed to the SQLObj so the attribute will be updated in the
>db.
>
>So I'm asking about what to do : adding a "passive mode" to SQLObject
>and add a "save" method to explicitly update, or adding a generated
>method getSomeClassDTO that would return the DTO.=20
>
>DTO could be implemented as a proxy over SQLObj : reading attribute on
>DTO will read on SQLObj, but setting attribute will store in a local
>cache, marking this attribute 'modified' so reading will read this
>modified value.
>
>If you have any idea about this problematic, I would appreciate a lot ;)
>
>Fran=E7ois
>
--=20
Matt Goodall, Pollenation Internet Ltd
e: ma...@po...
|