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 Frank Renaers <Fr...@ikan.be> on 2004/03/19 11:45:13 UTC

Strange behaviour of PersistenceBroker.retrieveAllReferences(obj);

Hi,

 

We are using OJB 1.0rc4 

Before doing an insert, we are using the PersistenceBroker
retrieveAllReferences to

resolve all references of our object.

But it seems that this method not only resolves all the references, but
also

generates a new oid.

Is this normal behaviour ?

In our application this causes some problems because we are doing

some business validations between retrieveAllReferences and the insert.

Is there a workaround for this ?

The oid should be generated during the insert !

 

-- Current behaviour --

1) retrieveAllReferences (GENERATES ALSO THE NEW OID ???)

2) business validations

3) insert

 

-- Expected behaviour --

1) retrieveAllReferences

2) business validations

3) insert ( + GENERATING THE NEW OID)

 

Thanks,

 

Frank Renaers - Ikan Software Belgium

 


Re: Strange behaviour of PersistenceBroker.retrieveAllReferences(obj);

Posted by Armin Waibel <ar...@apache.org>.
Hi Frank,

Frank Renaers wrote:
> Hi,
> 
>  
> 
> We are using OJB 1.0rc4 
> 
> Before doing an insert, we are using the PersistenceBroker
> retrieveAllReferences to
> 
> resolve all references of our object.
> 

Why you do try retrieve references for a new object? OJB couldn't find any.

> But it seems that this method not only resolves all the references, but
> also
> 
> generates a new oid.
> 
> Is this normal behaviour ?
> 

Indeed this should not happen. But it wasn't expected that this method 
was called with an new object.
The problem is BrokerHelper#getValuesForObject method. this method was 
indirectly called by PB#retrieveAll... method and does obtain new PK 
values from the sequence manager if not assigned.

> In our application this causes some problems because we are doing
> 
> some business validations between retrieveAllReferences and the insert.
> 
> Is there a workaround for this ?

Don't call this method when do an insert ;-)
I'm not sure if we should do an existence check in PB.retrieveAll... 
because this will be an performance issue and this method doesn't expect 
newly objects.

regards,
Armin

> 
> The oid should be generated during the insert !
> 
>  
> 
> -- Current behaviour --
> 
> 1) retrieveAllReferences (GENERATES ALSO THE NEW OID ???)
> 
> 2) business validations
> 
> 3) insert
> 
>  
> 
> -- Expected behaviour --
> 
> 1) retrieveAllReferences
> 
> 2) business validations
> 
> 3) insert ( + GENERATING THE NEW OID)
> 
>  
> 
> Thanks,
> 
>  
> 
> Frank Renaers - Ikan Software Belgium
> 
>  
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org