You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Armin Waibel <ar...@apache.org> on 2004/03/27 03:25:31 UTC

New auto-xxx handling

Hi all,

I checked in the new auto-update/-delete stuff. This should be 100% 
backward compatible with the old stuff.

auto-update/-delete now support the following values
none, link, object, false, true

BrokerHelper has new methods used to handle the new 'none' setting. 
These methods allow to assign/remove the FK in the referenced objects.

public void link(Object obj, boolean insert)
public boolean link(Object obj, String attributeName, boolean insert)
public void unlink(Object obj)
public boolean unlink(Object obj, String attributeName)

I added new test cases to check the new settings:
...broker.CollectionTest2
...broker.M2NTest
It is not possible to test all combinations of auto-xxx settings. If you 
miss some, please enhance these new tests. We need an similar test for 
1:1 relations too.

More details can be found in the "auto-xxx setting (PART II)" thread on 
dev-list and in near future in documentation (will start with this work 
today).

All test pass, but please review and check my made changes (maybe with 
your local tests).

regards,
Armin

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


Re: New auto-xxx handling

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

Jakob Braeuchi wrote:
> hi armin,
> 
> thanks for the great job :)
> there's an issue OJB245 which may affect the linkin/unlinking of objects.
> when unlinking fk-fields are set to 'null'. this is a problem when th fk 
> is part of the pk.
> 

wow! That seems true. I will try to fix this in PBImpl. Please review my 
changes, because it's a very critical part of OJB.

regards,
Armin

> this is the comment from OJB245 (line numbers from older revision !):
> 
> Creating and storing objects (A) with null reference to object (B), OJB 
> sets every FK_B in (A), part of PK_B to null. This is OK, except when 
> FK_B in A is part of PK of (A).
> 
> My hack:
> 
> --- PersistenceBrokerImpl.java
> +++ PersistenceBrokerImpl.java.new
> @@ -763,6 +763,7 @@
> 
>          for (int i = 0; i < objFkFields.length; i++)
>          {
> +            if( objFkFields[i].isPrimaryKey() == false )
>                  objFkFields[i].getPersistentField().set(realObj, 
> refPkValues != null ? refPkValues[i].getValue(): null);
>          }
>      }
> 
> 
> jakob
> 
> Armin Waibel wrote:
> 
>> Hi all,
>>
>> I checked in the new auto-update/-delete stuff. This should be 100% 
>> backward compatible with the old stuff.
>>
>> auto-update/-delete now support the following values
>> none, link, object, false, true
>>
>> BrokerHelper has new methods used to handle the new 'none' setting. 
>> These methods allow to assign/remove the FK in the referenced objects.
>>
>> public void link(Object obj, boolean insert)
>> public boolean link(Object obj, String attributeName, boolean insert)
>> public void unlink(Object obj)
>> public boolean unlink(Object obj, String attributeName)
>>
>> I added new test cases to check the new settings:
>> ...broker.CollectionTest2
>> ...broker.M2NTest
>> It is not possible to test all combinations of auto-xxx settings. If 
>> you miss some, please enhance these new tests. We need an similar test 
>> for 1:1 relations too.
>>
>> More details can be found in the "auto-xxx setting (PART II)" thread 
>> on dev-list and in near future in documentation (will start with this 
>> work today).
>>
>> All test pass, but please review and check my made changes (maybe with 
>> your local tests).
>>
>> regards,
>> Armin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

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


Re: New auto-xxx handling

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi armin,

thanks for the great job :)
there's an issue OJB245 which may affect the linkin/unlinking of objects.
when unlinking fk-fields are set to 'null'. this is a problem when th fk is part 
of the pk.

this is the comment from OJB245 (line numbers from older revision !):

Creating and storing objects (A) with null reference to object (B), OJB sets 
every FK_B in (A), part of PK_B to null. This is OK, except when FK_B in A is 
part of PK of (A).

My hack:

--- PersistenceBrokerImpl.java
+++ PersistenceBrokerImpl.java.new
@@ -763,6 +763,7 @@

          for (int i = 0; i < objFkFields.length; i++)
          {
+            if( objFkFields[i].isPrimaryKey() == false )
                  objFkFields[i].getPersistentField().set(realObj, refPkValues 
!= null ? refPkValues[i].getValue(): null);
          }
      }


jakob

Armin Waibel wrote:
> Hi all,
> 
> I checked in the new auto-update/-delete stuff. This should be 100% 
> backward compatible with the old stuff.
> 
> auto-update/-delete now support the following values
> none, link, object, false, true
> 
> BrokerHelper has new methods used to handle the new 'none' setting. 
> These methods allow to assign/remove the FK in the referenced objects.
> 
> public void link(Object obj, boolean insert)
> public boolean link(Object obj, String attributeName, boolean insert)
> public void unlink(Object obj)
> public boolean unlink(Object obj, String attributeName)
> 
> I added new test cases to check the new settings:
> ...broker.CollectionTest2
> ...broker.M2NTest
> It is not possible to test all combinations of auto-xxx settings. If you 
> miss some, please enhance these new tests. We need an similar test for 
> 1:1 relations too.
> 
> More details can be found in the "auto-xxx setting (PART II)" thread on 
> dev-list and in near future in documentation (will start with this work 
> today).
> 
> All test pass, but please review and check my made changes (maybe with 
> your local tests).
> 
> regards,
> Armin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 

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


Re: New auto-xxx handling

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

puh! It's done! The new auto-xxx stuff is complete (I'm sure I forget 
many user suggestions - sorry in advance ;-)), because the updated 
"Advanced O/R Mapping" doc is in CVS.

I introduce sub-sections about the auto-xxx settings in all section of 
1:1, 1:n and m:n relation.
Further the "Setting Load, Update, and Delete Cascading" was rewritten 
and contains new sub-sections. In particular a sub-section called "Link 
references" describes the handling of the new link/unlink methods with 
examples.

Please review my changes. thanks.

regards,
Armin

Armin Waibel wrote:

> Hi all,
> 
> I checked in the new auto-update/-delete stuff. This should be 100% 
> backward compatible with the old stuff.
> 
> auto-update/-delete now support the following values
> none, link, object, false, true
> 
> BrokerHelper has new methods used to handle the new 'none' setting. 
> These methods allow to assign/remove the FK in the referenced objects.
> 
> public void link(Object obj, boolean insert)
> public boolean link(Object obj, String attributeName, boolean insert)
> public void unlink(Object obj)
> public boolean unlink(Object obj, String attributeName)
> 
> I added new test cases to check the new settings:
> ...broker.CollectionTest2
> ...broker.M2NTest
> It is not possible to test all combinations of auto-xxx settings. If you 
> miss some, please enhance these new tests. We need an similar test for 
> 1:1 relations too.
> 
> More details can be found in the "auto-xxx setting (PART II)" thread on 
> dev-list and in near future in documentation (will start with this work 
> today).
> 
> All test pass, but please review and check my made changes (maybe with 
> your local tests).
> 
> regards,
> Armin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

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


Re: New auto-xxx handling

Posted by Antonio Gallardo <ag...@agssa.net>.
Thomas Dudziak dijo:
> One minor thing though: the advanced o/r page is too long now IMO, perhaps
> we should break it into smaller parts:
>
>  * associations/collections/auto-xxx/cascading
>  * inheritance and nesting
> (these two are not exactly part of advanced o/r :)
>  * proxying
>  * misc (row-readers, callbacks, customized queries)

+1 It is a good idea.

Best Regards,

Antonio Gallardo


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


Re: New auto-xxx handling

Posted by Thomas Dudziak <to...@first.gmd.de>.
On Sat, 27 Mar 2004, Armin Waibel wrote:

> Hi all,
> 
> I checked in the new auto-update/-delete stuff. This should be 100% 
> backward compatible with the old stuff.
> 
> auto-update/-delete now support the following values
> none, link, object, false, true
> 
> BrokerHelper has new methods used to handle the new 'none' setting. 
> These methods allow to assign/remove the FK in the referenced objects.
> 
> public void link(Object obj, boolean insert)
> public boolean link(Object obj, String attributeName, boolean insert)
> public void unlink(Object obj)
> public boolean unlink(Object obj, String attributeName)
> 
> I added new test cases to check the new settings:
> ...broker.CollectionTest2
> ...broker.M2NTest
> It is not possible to test all combinations of auto-xxx settings. If you 
> miss some, please enhance these new tests. We need an similar test for 
> 1:1 relations too.
> 
> More details can be found in the "auto-xxx setting (PART II)" thread on 
> dev-list and in near future in documentation (will start with this work 
> today).

I just had to use the new documentation (looking up how manually retrieve
a reference), and I must say, great doc !

One minor thing though: the advanced o/r page is too long now IMO, perhaps
we should break it into smaller parts:

 * associations/collections/auto-xxx/cascading
 * inheritance and nesting
(these two are not exactly part of advanced o/r :)
 * proxying
 * misc (row-readers, callbacks, customized queries)

Tom


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