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 "Robert S. Sfeir" <ro...@sfeir.net> on 2003/02/16 21:11:43 UTC

Update not quite working

I was looking at tutorial 2, and looking at how to update an item in 
the DB.

The question I have is if I have the code below:

	public void updateHome( HomeBO home ) throws DataAccessException
	{
		Transaction tx = odmg.newTransaction();
		try
		{
			tx.begin();
			tx.lock( home , tx.WRITE );
			tx.commit();
		}
		catch( Exception e )
		{
			tx.abort();
			if( log.isFatalEnabled() )
				log.fatal( "An exception occured during database processing" , e );
		}
	}

I would think that since HomeBO contains all the information that I 
want to update that I can pass it directly to the tx.lock() for 
updating.  It even contains the home.getHomeID() which is the primary 
key and defined in the repository as such.  Am I mistaken here or do I 
still need to do the Select of the item to be udpate, do all the sets 
Then do the commit?  If so, that's a bummer because having to do all 
that is almost just as much as writing my own sql :-\

Hopefully I'm missing a piece.

R


Re: Update not quite working

Posted by "Robert S. Sfeir" <ro...@sfeir.net>.
I forgot to mention that yes it DOES work if I do a select first.  Just 
trying to see if there is a better way.

R
On Sunday, Feb 16, 2003, at 15:11 US/Eastern, Robert S. Sfeir wrote:

> I was looking at tutorial 2, and looking at how to update an item in 
> the DB.
>
> The question I have is if I have the code below:
>
> 	public void updateHome( HomeBO home ) throws DataAccessException
> 	{
> 		Transaction tx = odmg.newTransaction();
> 		try
> 		{
> 			tx.begin();
> 			tx.lock( home , tx.WRITE );
> 			tx.commit();
> 		}
> 		catch( Exception e )
> 		{
> 			tx.abort();
> 			if( log.isFatalEnabled() )
> 				log.fatal( "An exception occured during database processing" , e );
> 		}
> 	}
>
> I would think that since HomeBO contains all the information that I 
> want to update that I can pass it directly to the tx.lock() for 
> updating.  It even contains the home.getHomeID() which is the primary 
> key and defined in the repository as such.  Am I mistaken here or do I 
> still need to do the Select of the item to be udpate, do all the sets 
> Then do the commit?  If so, that's a bummer because having to do all 
> that is almost just as much as writing my own sql :-\
>
> Hopefully I'm missing a piece.
>
> R
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>