You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Kevin Viet <vi...@activia.net> on 2002/11/29 11:31:38 UTC

design 2

Hello all 

There's something in Ojb that I can understand in updating an existing
object

For broker API a call to : broker.save(obj); is only necessary to update
the db.

For ODMG Api there's no such method and updating an object is done by
using some setXXX() methods between transaction bounds:

tx.begin ()
tx.lock(customer, WRITE) 
customer.setName(name);
...
tx.commit();


I want to create an interface on top of OJB layer (for hiding ojb), if I
use the broker API it's easy to design a method to update an object in
the repository :
	public void update(Object object) throws DBException;
The object in arguments has already been modified by application code
and then application request that the object have to be updated in the
repository.

Using the same considerations, things getting harder if I want to use
the ODMG Api because of the transaction things.
In fact the update method can't be so generic because of the call of
particular model setXXX(), I will have to define an update method for
every model objects and pass the values to be modified to this method

public void udpateCustomer(Customer cust, String firstName, String
lastName, int age)
{
	tx.begin();
	cust.setFirstName(firstName);
	cust.setLastName(lastName);
	tx.commit();
}

Writing such methods can be painfull but not impossible ...

Anyone got a better idea to simplify my life ... ?
Thx


-- 
Kevin Viet <vi...@activia.net>
ActiVia Networks




Re: design 2

Posted by Thomas Mahler <th...@apache.org>.
Hi Kevin,

An hour ago I posted the following design principles for an abstraction 
layer:
http://archives.apache.org/eyebrowse/ReadMsg?listName=ojb-user@jakarta.apache.org&msgNo=4226

cheers,
Thomas

Kevin Viet wrote:
> Hello all 
> 
> There's something in Ojb that I can understand in updating an existing
> object
> 
> For broker API a call to : broker.save(obj); is only necessary to update
> the db.
> 
> For ODMG Api there's no such method and updating an object is done by
> using some setXXX() methods between transaction bounds:
> 
> tx.begin ()
> tx.lock(customer, WRITE) 
> customer.setName(name);
> ...
> tx.commit();
> 
> 
> I want to create an interface on top of OJB layer (for hiding ojb), if I
> use the broker API it's easy to design a method to update an object in
> the repository :
> 	public void update(Object object) throws DBException;
> The object in arguments has already been modified by application code
> and then application request that the object have to be updated in the
> repository.
> 
> Using the same considerations, things getting harder if I want to use
> the ODMG Api because of the transaction things.
> In fact the update method can't be so generic because of the call of
> particular model setXXX(), I will have to define an update method for
> every model objects and pass the values to be modified to this method
> 
> public void udpateCustomer(Customer cust, String firstName, String
> lastName, int age)
> {
> 	tx.begin();
> 	cust.setFirstName(firstName);
> 	cust.setLastName(lastName);
> 	tx.commit();
> }
> 
> Writing such methods can be painfull but not impossible ...
> 
> Anyone got a better idea to simplify my life ... ?
> Thx
> 
>