You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "Akins, Greg" <ga...@amervideo.com> on 2005/04/13 15:34:09 UTC

getting database copy rather than existing object, or cached copy

I'm trying to compare what's in the database against what an object
currently is...
 
So I thought this would work
 
Status oldStatus =
((HoldAvp)adao.getObjectById(holdAvp.getId())).getStatus() ;
Status newStatus = holdAvp.getStatus() ;
 
However, oldStatus has the updated value, even though I can see in the
database it hasn't been updated yet.
 
Can I use Ibatis to get the current database value?  Or do I have to use
JDBC?  Or am I thinking about this the wrong way?
 
Greg Akins
Software Engineer
Sony Electronics, STP Systems
724.696.7322 (Sony)
724.696.6147 (AV)
724.454.7790 (Cell)
412.590.3973 (Pager)
 

Re: getting database copy rather than existing object, or cached copy

Posted by Brandon Goodin <br...@gmail.com>.
iBatis will retrieve a fresh object from the database each time. Are
you using a cache on your mapped statement for getObjectById(...)?

Brandon

On 4/13/05, Akins, Greg <ga...@amervideo.com> wrote:
>  
> I'm trying to compare what's in the database against what an object
> currently is... 
>   
> So I thought this would work 
>   
> Status oldStatus =
> ((HoldAvp)adao.getObjectById(holdAvp.getId())).getStatus() ;
> Status newStatus = holdAvp.getStatus() ; 
>   
> However, oldStatus has the updated value, even though I can see in the
> database it hasn't been updated yet. 
>   
> Can I use Ibatis to get the current database value?  Or do I have to use
> JDBC?  Or am I thinking about this the wrong way? 
>   
>  
> Greg Akins 
> Software Engineer 
> Sony Electronics, STP Systems 
> 724.696.7322 (Sony) 
> 724.696.6147 (AV) 
> 724.454.7790 (Cell) 
> 412.590.3973 (Pager) 
>