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 Bobby Lawrence <ro...@jlab.org> on 2005/05/11 15:22:42 UTC

question about collection references...

How does OJB handle collection references internally?
If I have an object that contains a collection of  other objects, and I 
remove one, will OJB remove that same one from the database?
Does OJB check the collection in the database and see that there is one 
more than the the collection it is about to persist and delete that one?
Also - if I have a collection that contains only one object and I change 
the primary key, does OJB update that object or insert a new one?
I seems like the latter...

-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------





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


Re: P6Spy config

Posted by Armin Waibel <ar...@apache.org>.
Bobby Lawrence wrote:
> I have only used one appender at a time, and I assume that the 
> spy.properties file is used because OBJ does go to the correct database, 
> even when I tell it to use the P6Spy driver.
> I just see no logging...
>

Strangely! I don't have problems using p6spy with OJB, but I don't use 
it within an appServer. Does the appServer suppress logging to stdout or 
from specific packages?
Sorry, I'm at my wits end.

regards,
Armin

> 
> Armin Waibel wrote:
> 
>> Hi,
>>
>> is the spy.properties file used (you have access to your DB)?
>> Did you only enable *one* appender at a time? Did your appServer show 
>> logging to stdout?
>>
>> regards,
>> Armin
>>
>> robertl@jlab.org wrote:
>>
>>> Ok -
>>> Still no P6Spy logging...
>>> I have used both appenders (File and StdOut), but nothing.
>>> I have the spy.properties file in my EJB Jar, which is deployed 
>>> inside an
>>> EAR.  The OJB lib is in my EAR along with the EJBs.
>>> Any ideas?
>>>
>>>
>>>
>>>> Bobby Lawrence wrote:
>>>>
>>>>> Damn -
>>>>> Thanks Armin.  I have been ripping out my hair trying to figure 
>>>>> this one
>>>>> out.
>>>>> I appreciate it.
>>>>> I guess I will have to change my implementation.
>>>>> Also - for some reason, I can't get the P6Spy stuff to work either...
>>>>> I have that listed as my driver, and I have the spy.properties file
>>>>> containing my realdriver class, but I get no debugging statements...
>>>>> Any idea?
>>>>
>>>>
>>>>
>>>> If you use the spy.properties file shipped with OJB all sql will be
>>>> logged in a file call "spy.log". You can change the 'appender' in
>>>> spy.properties file.
>>>> Recommend to use the patched version p6spy shipped with OJB (this
>>>> version only log the sql queries without result sets).
>>>>
>>>> regards,
>>>> Armin
>>>>
>>>>
>>>>
>>>>> --Bobby
>>>>>
>>>>> Armin Waibel wrote:
>>>>>
>>>>>
>>>>>> Hi Bobby,
>>>>>>
>>>>>> Bobby Lawrence wrote:
>>>>>>
>>>>>>
>>>>>>> OK - This is frustrating...
>>>>>>> OJB will NOT delete objects in the database that are no longer in my
>>>>>>> collection.
>>>>>>> I have an object that stores an array of other objects as a
>>>>>>> collection-reference.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Using an Array as collection reference is completely different from
>>>>>> using a java-Collection. In the second case OJB can take care of
>>>>>> removed objects when using e.g. RemovalAwareCollection/List for
>>>>>> Collection/List fields. When using arrays this is not possible.
>>>>>> (in contrast to the odmg-api, the PB-api doesn't track object
>>>>>> modifications, so to notice removed objects a specific collection
>>>>>> implementation is needed for collection-reference fields).
>>>>>> Sorry I didn't notice that you are using an array before this post.
>>>>>>
>>>>>> regards,
>>>>>> Armin
>>>>>>
>>>>>>
>>>>>>
>>>>>>> The collection-descirptor has attributes auto-update="object",
>>>>>>> auto-delete="object".
>>>>>>> Now, when I remove objects from the array in the parent and call
>>>>>>> PersistenceBroker.store(parent), the objects that were in my array%0
>>>>>>
>>>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
> 

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


Re: P6Spy config

Posted by Bobby Lawrence <ro...@jlab.org>.
I have only used one appender at a time, and I assume that the 
spy.properties file is used because OBJ does go to the correct database, 
even when I tell it to use the P6Spy driver.
I just see no logging...


Armin Waibel wrote:

> Hi,
>
> is the spy.properties file used (you have access to your DB)?
> Did you only enable *one* appender at a time? Did your appServer show 
> logging to stdout?
>
> regards,
> Armin
>
> robertl@jlab.org wrote:
>
>> Ok -
>> Still no P6Spy logging...
>> I have used both appenders (File and StdOut), but nothing.
>> I have the spy.properties file in my EJB Jar, which is deployed 
>> inside an
>> EAR.  The OJB lib is in my EAR along with the EJBs.
>> Any ideas?
>>
>>
>>
>>> Bobby Lawrence wrote:
>>>
>>>> Damn -
>>>> Thanks Armin.  I have been ripping out my hair trying to figure 
>>>> this one
>>>> out.
>>>> I appreciate it.
>>>> I guess I will have to change my implementation.
>>>> Also - for some reason, I can't get the P6Spy stuff to work either...
>>>> I have that listed as my driver, and I have the spy.properties file
>>>> containing my realdriver class, but I get no debugging statements...
>>>> Any idea?
>>>
>>>
>>> If you use the spy.properties file shipped with OJB all sql will be
>>> logged in a file call "spy.log". You can change the 'appender' in
>>> spy.properties file.
>>> Recommend to use the patched version p6spy shipped with OJB (this
>>> version only log the sql queries without result sets).
>>>
>>> regards,
>>> Armin
>>>
>>>
>>>
>>>> --Bobby
>>>>
>>>> Armin Waibel wrote:
>>>>
>>>>
>>>>> Hi Bobby,
>>>>>
>>>>> Bobby Lawrence wrote:
>>>>>
>>>>>
>>>>>> OK - This is frustrating...
>>>>>> OJB will NOT delete objects in the database that are no longer in my
>>>>>> collection.
>>>>>> I have an object that stores an array of other objects as a
>>>>>> collection-reference.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Using an Array as collection reference is completely different from
>>>>> using a java-Collection. In the second case OJB can take care of
>>>>> removed objects when using e.g. RemovalAwareCollection/List for
>>>>> Collection/List fields. When using arrays this is not possible.
>>>>> (in contrast to the odmg-api, the PB-api doesn't track object
>>>>> modifications, so to notice removed objects a specific collection
>>>>> implementation is needed for collection-reference fields).
>>>>> Sorry I didn't notice that you are using an array before this post.
>>>>>
>>>>> regards,
>>>>> Armin
>>>>>
>>>>>
>>>>>
>>>>>> The collection-descirptor has attributes auto-update="object",
>>>>>> auto-delete="object".
>>>>>> Now, when I remove objects from the array in the parent and call
>>>>>> PersistenceBroker.store(parent), the objects that were in my array%0
>>>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>

-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------





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


Re: P6Spy config

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

is the spy.properties file used (you have access to your DB)?
Did you only enable *one* appender at a time? Did your appServer show 
logging to stdout?

regards,
Armin

robertl@jlab.org wrote:
> Ok -
> Still no P6Spy logging...
> I have used both appenders (File and StdOut), but nothing.
> I have the spy.properties file in my EJB Jar, which is deployed inside an
> EAR.  The OJB lib is in my EAR along with the EJBs.
> Any ideas?
> 
> 
> 
>>Bobby Lawrence wrote:
>>
>>>Damn -
>>>Thanks Armin.  I have been ripping out my hair trying to figure this one
>>>out.
>>>I appreciate it.
>>>I guess I will have to change my implementation.
>>>Also - for some reason, I can't get the P6Spy stuff to work either...
>>>I have that listed as my driver, and I have the spy.properties file
>>>containing my realdriver class, but I get no debugging statements...
>>>Any idea?
>>
>>If you use the spy.properties file shipped with OJB all sql will be
>>logged in a file call "spy.log". You can change the 'appender' in
>>spy.properties file.
>>Recommend to use the patched version p6spy shipped with OJB (this
>>version only log the sql queries without result sets).
>>
>>regards,
>>Armin
>>
>>
>>
>>>--Bobby
>>>
>>>Armin Waibel wrote:
>>>
>>>
>>>>Hi Bobby,
>>>>
>>>>Bobby Lawrence wrote:
>>>>
>>>>
>>>>>OK - This is frustrating...
>>>>>OJB will NOT delete objects in the database that are no longer in my
>>>>>collection.
>>>>>I have an object that stores an array of other objects as a
>>>>>collection-reference.
>>>>
>>>>
>>>>
>>>>Using an Array as collection reference is completely different from
>>>>using a java-Collection. In the second case OJB can take care of
>>>>removed objects when using e.g. RemovalAwareCollection/List for
>>>>Collection/List fields. When using arrays this is not possible.
>>>>(in contrast to the odmg-api, the PB-api doesn't track object
>>>>modifications, so to notice removed objects a specific collection
>>>>implementation is needed for collection-reference fields).
>>>>Sorry I didn't notice that you are using an array before this post.
>>>>
>>>>regards,
>>>>Armin
>>>>
>>>>
>>>>
>>>>>The collection-descirptor has attributes auto-update="object",
>>>>>auto-delete="object".
>>>>>Now, when I remove objects from the array in the parent and call
>>>>>PersistenceBroker.store(parent), the objects that were in my array%0
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

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


P6Spy config

Posted by ro...@jlab.org.
Ok -
Still no P6Spy logging...
I have used both appenders (File and StdOut), but nothing.
I have the spy.properties file in my EJB Jar, which is deployed inside an
EAR.  The OJB lib is in my EAR along with the EJBs.
Any ideas?


> Bobby Lawrence wrote:
>> Damn -
>> Thanks Armin.  I have been ripping out my hair trying to figure this one
>> out.
>> I appreciate it.
>> I guess I will have to change my implementation.
>> Also - for some reason, I can't get the P6Spy stuff to work either...
>> I have that listed as my driver, and I have the spy.properties file
>> containing my realdriver class, but I get no debugging statements...
>> Any idea?
>
> If you use the spy.properties file shipped with OJB all sql will be
> logged in a file call "spy.log". You can change the 'appender' in
> spy.properties file.
> Recommend to use the patched version p6spy shipped with OJB (this
> version only log the sql queries without result sets).
>
> regards,
> Armin
>
>
>> --Bobby
>>
>> Armin Waibel wrote:
>>
>>> Hi Bobby,
>>>
>>> Bobby Lawrence wrote:
>>>
>>>> OK - This is frustrating...
>>>> OJB will NOT delete objects in the database that are no longer in my
>>>> collection.
>>>> I have an object that stores an array of other objects as a
>>>> collection-reference.
>>>
>>>
>>>
>>> Using an Array as collection reference is completely different from
>>> using a java-Collection. In the second case OJB can take care of
>>> removed objects when using e.g. RemovalAwareCollection/List for
>>> Collection/List fields. When using arrays this is not possible.
>>> (in contrast to the odmg-api, the PB-api doesn't track object
>>> modifications, so to notice removed objects a specific collection
>>> implementation is needed for collection-reference fields).
>>> Sorry I didn't notice that you are using an array before this post.
>>>
>>> regards,
>>> Armin
>>>
>>>
>>>> The collection-descirptor has attributes auto-update="object",
>>>> auto-delete="object".
>>>> Now, when I remove objects from the array in the parent and call
>>>> PersistenceBroker.store(parent), the objects that were in my array%0


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


Re: question about collection references...

Posted by Armin Waibel <ar...@apache.org>.
Bobby Lawrence wrote:
> Damn -
> Thanks Armin.  I have been ripping out my hair trying to figure this one 
> out.
> I appreciate it.
> I guess I will have to change my implementation.
> Also - for some reason, I can't get the P6Spy stuff to work either...
> I have that listed as my driver, and I have the spy.properties file 
> containing my realdriver class, but I get no debugging statements...
> Any idea?

If you use the spy.properties file shipped with OJB all sql will be 
logged in a file call "spy.log". You can change the 'appender' in 
spy.properties file.
Recommend to use the patched version p6spy shipped with OJB (this 
version only log the sql queries without result sets).

regards,
Armin


> --Bobby
> 
> Armin Waibel wrote:
> 
>> Hi Bobby,
>>
>> Bobby Lawrence wrote:
>>
>>> OK - This is frustrating...
>>> OJB will NOT delete objects in the database that are no longer in my 
>>> collection.
>>> I have an object that stores an array of other objects as a 
>>> collection-reference.
>>
>>
>>
>> Using an Array as collection reference is completely different from 
>> using a java-Collection. In the second case OJB can take care of 
>> removed objects when using e.g. RemovalAwareCollection/List for 
>> Collection/List fields. When using arrays this is not possible.
>> (in contrast to the odmg-api, the PB-api doesn't track object 
>> modifications, so to notice removed objects a specific collection 
>> implementation is needed for collection-reference fields).
>> Sorry I didn't notice that you are using an array before this post.
>>
>> regards,
>> Armin
>>
>>
>>> The collection-descirptor has attributes auto-update="object", 
>>> auto-delete="object".
>>> Now, when I remove objects from the array in the parent and call 
>>> PersistenceBroker.store(parent), the objects that were in my array 
>>> are NOT deleted in the database.  What happens is, OJB simply updates 
>>> the objects that it does have in the array.
>>> If my array contains 3 objects, I remove one, OJB updates 2 and fails 
>>> to delete the remaining 1.
>>> Any ideas?
>>> I have run out...
>>> --Bobby
>>>
>>>
>>>
>>> Robert r. Sanders wrote:
>>>
>>>>
>>>>
>>>> Bobby Lawrence wrote:
>>>>
>>>>> How does OJB handle collection references internally?
>>>>> If I have an object that contains a collection of  other objects, 
>>>>> and I remove one, will OJB remove that same one from the database?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> If you use that API correctly (see the tutorials), then yes, OJB 
>>>> with track changes to collections, etc... Typical setup is so that 
>>>> if you remove an object from a collection the foriegn key is removed 
>>>> in the DB, but the actual 'object'/row is still there unless you 
>>>> explicitly delete this.  I can't remember off the top of my head, 
>>>> but I believe there is a configuration option (per-collection) to 
>>>> change this so a remove == a db delete.
>>>>
>>>>> Also - if I have a collection that contains only one object and I 
>>>>> change the primary key, does OJB update that object or insert a new 
>>>>> one?
>>>>> I seems like the latter...
>>>>>
>>>> You should let OJB handle the primary (and foreign) keys for you; 
>>>> they end up being the items that OJB is using to track object 
>>>> identity, so the behavior that your seeing is not unexpected 
>>>> (changing the primary key essentially changes the object reference 
>>>> as far as the SQL portion of OJB is concerned).
>>>
>>>
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
> 

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


Re: question about collection references...

Posted by Bobby Lawrence <ro...@jlab.org>.
Damn -
Thanks Armin.  I have been ripping out my hair trying to figure this one 
out.
I appreciate it.
I guess I will have to change my implementation.
Also - for some reason, I can't get the P6Spy stuff to work either...
I have that listed as my driver, and I have the spy.properties file 
containing my realdriver class, but I get no debugging statements...
Any idea?
--Bobby

Armin Waibel wrote:

> Hi Bobby,
>
> Bobby Lawrence wrote:
>
>> OK - This is frustrating...
>> OJB will NOT delete objects in the database that are no longer in my 
>> collection.
>> I have an object that stores an array of other objects as a 
>> collection-reference.
>
>
> Using an Array as collection reference is completely different from 
> using a java-Collection. In the second case OJB can take care of 
> removed objects when using e.g. RemovalAwareCollection/List for 
> Collection/List fields. When using arrays this is not possible.
> (in contrast to the odmg-api, the PB-api doesn't track object 
> modifications, so to notice removed objects a specific collection 
> implementation is needed for collection-reference fields).
> Sorry I didn't notice that you are using an array before this post.
>
> regards,
> Armin
>
>
>> The collection-descirptor has attributes auto-update="object", 
>> auto-delete="object".
>> Now, when I remove objects from the array in the parent and call 
>> PersistenceBroker.store(parent), the objects that were in my array 
>> are NOT deleted in the database.  What happens is, OJB simply updates 
>> the objects that it does have in the array.
>> If my array contains 3 objects, I remove one, OJB updates 2 and fails 
>> to delete the remaining 1.
>> Any ideas?
>> I have run out...
>> --Bobby
>>
>>
>>
>> Robert r. Sanders wrote:
>>
>>>
>>>
>>> Bobby Lawrence wrote:
>>>
>>>> How does OJB handle collection references internally?
>>>> If I have an object that contains a collection of  other objects, 
>>>> and I remove one, will OJB remove that same one from the database?
>>>
>>>
>>>
>>>
>>> If you use that API correctly (see the tutorials), then yes, OJB 
>>> with track changes to collections, etc... Typical setup is so that 
>>> if you remove an object from a collection the foriegn key is removed 
>>> in the DB, but the actual 'object'/row is still there unless you 
>>> explicitly delete this.  I can't remember off the top of my head, 
>>> but I believe there is a configuration option (per-collection) to 
>>> change this so a remove == a db delete.
>>>
>>>> Also - if I have a collection that contains only one object and I 
>>>> change the primary key, does OJB update that object or insert a new 
>>>> one?
>>>> I seems like the latter...
>>>>
>>> You should let OJB handle the primary (and foreign) keys for you; 
>>> they end up being the items that OJB is using to track object 
>>> identity, so the behavior that your seeing is not unexpected 
>>> (changing the primary key essentially changes the object reference 
>>> as far as the SQL portion of OJB is concerned).
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>

-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------





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


Re: question about collection references...

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

Bobby Lawrence wrote:
> OK - This is frustrating...
> OJB will NOT delete objects in the database that are no longer in my 
> collection.
> I have an object that stores an array of other objects as a 
> collection-reference.

Using an Array as collection reference is completely different from 
using a java-Collection. In the second case OJB can take care of removed 
objects when using e.g. RemovalAwareCollection/List for Collection/List 
fields. When using arrays this is not possible.
(in contrast to the odmg-api, the PB-api doesn't track object 
modifications, so to notice removed objects a specific collection 
implementation is needed for collection-reference fields).
Sorry I didn't notice that you are using an array before this post.

regards,
Armin


> The collection-descirptor has attributes auto-update="object", 
> auto-delete="object".
> Now, when I remove objects from the array in the parent and call 
> PersistenceBroker.store(parent), the objects that were in my array are 
> NOT deleted in the database.  What happens is, OJB simply updates the 
> objects that it does have in the array.
> If my array contains 3 objects, I remove one, OJB updates 2 and fails to 
> delete the remaining 1.
> Any ideas?
> I have run out...
> --Bobby
> 
> 
> 
> Robert r. Sanders wrote:
> 
>>
>>
>> Bobby Lawrence wrote:
>>
>>> How does OJB handle collection references internally?
>>> If I have an object that contains a collection of  other objects, and 
>>> I remove one, will OJB remove that same one from the database?
>>
>>
>>
>> If you use that API correctly (see the tutorials), then yes, OJB with 
>> track changes to collections, etc... Typical setup is so that if you 
>> remove an object from a collection the foriegn key is removed in the 
>> DB, but the actual 'object'/row is still there unless you explicitly 
>> delete this.  I can't remember off the top of my head, but I believe 
>> there is a configuration option (per-collection) to change this so a 
>> remove == a db delete.
>>
>>> Also - if I have a collection that contains only one object and I 
>>> change the primary key, does OJB update that object or insert a new one?
>>> I seems like the latter...
>>>
>> You should let OJB handle the primary (and foreign) keys for you; they 
>> end up being the items that OJB is using to track object identity, so 
>> the behavior that your seeing is not unexpected (changing the primary 
>> key essentially changes the object reference as far as the SQL portion 
>> of OJB is concerned).
> 
> 
> 

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


Re: question about collection references...

Posted by Bobby Lawrence <ro...@jlab.org>.
OK - This is frustrating...
OJB will NOT delete objects in the database that are no longer in my 
collection.
I have an object that stores an array of other objects as a 
collection-reference.
The collection-descirptor has attributes auto-update="object", 
auto-delete="object".
Now, when I remove objects from the array in the parent and call 
PersistenceBroker.store(parent), the objects that were in my array are 
NOT deleted in the database.  What happens is, OJB simply updates the 
objects that it does have in the array.
If my array contains 3 objects, I remove one, OJB updates 2 and fails to 
delete the remaining 1.
Any ideas?
I have run out...
--Bobby



Robert r. Sanders wrote:

>
>
> Bobby Lawrence wrote:
>
>> How does OJB handle collection references internally?
>> If I have an object that contains a collection of  other objects, and 
>> I remove one, will OJB remove that same one from the database?
>
>
> If you use that API correctly (see the tutorials), then yes, OJB with 
> track changes to collections, etc... Typical setup is so that if you 
> remove an object from a collection the foriegn key is removed in the 
> DB, but the actual 'object'/row is still there unless you explicitly 
> delete this.  I can't remember off the top of my head, but I believe 
> there is a configuration option (per-collection) to change this so a 
> remove == a db delete.
>
>> Also - if I have a collection that contains only one object and I 
>> change the primary key, does OJB update that object or insert a new one?
>> I seems like the latter...
>>
> You should let OJB handle the primary (and foreign) keys for you; they 
> end up being the items that OJB is using to track object identity, so 
> the behavior that your seeing is not unexpected (changing the primary 
> key essentially changes the object reference as far as the SQL portion 
> of OJB is concerned).


-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------





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


Re: question about collection references...

Posted by "Robert r. Sanders" <ro...@ipov.net>.
Bobby Lawrence wrote:

> Thanx Robert.
> I am letting OJB handle the PK/FK stuff - that is the problem is seems.
> I have one object, but I want to change a field...this field is a PK.  
> I want OBJ to update, but it inserts a new one...
> --Bobby
>
I could be wrong as I am not very familiar w/ the internals of OJB's 
code, maybe one of the commiters can help more, but my understanding is 
that if you change a PK then OJB is going to interpret this as 
new/different object than before, since the PK is what it is using to 
track identity. You can setup SQL debugging to see the exact statements 
generated; but my guess is that the best you are going to be able to do 
is:  clone your Object, delete the old object, add the new object (using 
a custom sequence manager).  If you really want to take things into your 
own hands I guess you could get a java.sql.Connection object from OJB 
and use that to issue SQL update commands, then flush the object cache...


-- 
    Robert r. Sanders
    Chief Technologist
    iPOV
    (334) 821-5412
    www.ipov.net


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


Re: question about collection references...

Posted by Carlos Chávez <cc...@agssa.net>.
Bobby Lawrence Escribio :-)
> Thanx Carlos - I have and it doesn't help.

  The other option is delete the current object from de collection
  and then add the new object.

  Cheers.
  Carlos Chávez.
>
>
> Carlos Chávez wrote:
>
>> Hi Bobby.
>>
>> try to update the reference to the object too.
>>
>> Cheers.
>> Carlos Chávez.
>>
>>Bobby Lawrence Escribio :-)
>>
>>
>>>Thanx Robert.
>>>I am letting OJB handle the PK/FK stuff - that is the problem is seems.
>>>I have one object, but I want to change a field...this field is a PK.  I
>>>want OBJ to update, but it inserts a new one...
>>>--Bobby
>>>
>>>Robert r. Sanders wrote:
>>>
>>>
>>>
>>>>Bobby Lawrence wrote:
>>>>
>>>>
>>>>
>>>>>How does OJB handle collection references internally?
>>>>>If I have an object that contains a collection of  other objects, and
>>>>>I remove one, will OJB remove that same one from the database?
>>>>>
>>>>>
>>>>If you use that API correctly (see the tutorials), then yes, OJB with
>>>>track changes to collections, etc... Typical setup is so that if you
>>>>remove an object from a collection the foriegn key is removed in the
>>>>DB, but the actual 'object'/row is still there unless you explicitly
>>>>delete this.  I can't remember off the top of my head, but I believe
>>>>there is a configuration option (per-collection) to change this so a
>>>>remove == a db delete.
>>>>
>>>>
>>>>
>>>>>Also - if I have a collection that contains only one object and I
>>>>>change the primary key, does OJB update that object or insert a new
>>>>>one?
>>>>>I seems like the latter...
>>>>>
>>>>>
>>>>>
>>>>You should let OJB handle the primary (and foreign) keys for you; they
>>>>end up being the items that OJB is using to track object identity, so
>>>>the behavior that your seeing is not unexpected (changing the primary
>>>>key essentially changes the object reference as far as the SQL portion
>>>>of OJB is concerned).
>>>>
>>>>
>>>--
>>>----------------------------
>>>Bobby Lawrence
>>>MIS Application Developer
>>>
>>>Jefferson Lab (www.jlab.org)
>>>
>>> Email: robertl@jlab.org
>>>Office: (757) 269-5818
>>> Pager: (757) 584-5818
>>>----------------------------
>>>
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>>
>>
>>
>
> --
> ----------------------------
> Bobby Lawrence
> MIS Application Developer
>
> Jefferson Lab (www.jlab.org)
>
>  Email: robertl@jlab.org
> Office: (757) 269-5818
>  Pager: (757) 584-5818
> ----------------------------
>
>
>


-- 
Carlos Chávez

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


Re: question about collection references...

Posted by Bobby Lawrence <ro...@jlab.org>.
Thanx Carlos - I have and it doesn't help.


Carlos Chávez wrote:

> Hi Bobby.
>
> try to update the reference to the object too.
>
> Cheers.
> Carlos Chávez.
>
>Bobby Lawrence Escribio :-)
>  
>
>>Thanx Robert.
>>I am letting OJB handle the PK/FK stuff - that is the problem is seems.
>>I have one object, but I want to change a field...this field is a PK.  I
>>want OBJ to update, but it inserts a new one...
>>--Bobby
>>
>>Robert r. Sanders wrote:
>>
>>    
>>
>>>Bobby Lawrence wrote:
>>>
>>>      
>>>
>>>>How does OJB handle collection references internally?
>>>>If I have an object that contains a collection of  other objects, and
>>>>I remove one, will OJB remove that same one from the database?
>>>>        
>>>>
>>>If you use that API correctly (see the tutorials), then yes, OJB with
>>>track changes to collections, etc... Typical setup is so that if you
>>>remove an object from a collection the foriegn key is removed in the
>>>DB, but the actual 'object'/row is still there unless you explicitly
>>>delete this.  I can't remember off the top of my head, but I believe
>>>there is a configuration option (per-collection) to change this so a
>>>remove == a db delete.
>>>
>>>      
>>>
>>>>Also - if I have a collection that contains only one object and I
>>>>change the primary key, does OJB update that object or insert a new
>>>>one?
>>>>I seems like the latter...
>>>>
>>>>        
>>>>
>>>You should let OJB handle the primary (and foreign) keys for you; they
>>>end up being the items that OJB is using to track object identity, so
>>>the behavior that your seeing is not unexpected (changing the primary
>>>key essentially changes the object reference as far as the SQL portion
>>>of OJB is concerned).
>>>      
>>>
>>--
>>----------------------------
>>Bobby Lawrence
>>MIS Application Developer
>>
>>Jefferson Lab (www.jlab.org)
>>
>> Email: robertl@jlab.org
>>Office: (757) 269-5818
>> Pager: (757) 584-5818
>>----------------------------
>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>    
>>
>
>
>  
>

-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------



Re: question about collection references...

Posted by Carlos Chávez <cc...@agssa.net>.
 Hi Bobby.

 try to update the reference to the object too.

 Cheers.
 Carlos Chávez.

Bobby Lawrence Escribio :-)
> Thanx Robert.
> I am letting OJB handle the PK/FK stuff - that is the problem is seems.
> I have one object, but I want to change a field...this field is a PK.  I
> want OBJ to update, but it inserts a new one...
> --Bobby
>
> Robert r. Sanders wrote:
>
>>
>>
>> Bobby Lawrence wrote:
>>
>>> How does OJB handle collection references internally?
>>> If I have an object that contains a collection of  other objects, and
>>> I remove one, will OJB remove that same one from the database?
>>
>>
>> If you use that API correctly (see the tutorials), then yes, OJB with
>> track changes to collections, etc... Typical setup is so that if you
>> remove an object from a collection the foriegn key is removed in the
>> DB, but the actual 'object'/row is still there unless you explicitly
>> delete this.  I can't remember off the top of my head, but I believe
>> there is a configuration option (per-collection) to change this so a
>> remove == a db delete.
>>
>>> Also - if I have a collection that contains only one object and I
>>> change the primary key, does OJB update that object or insert a new
>>> one?
>>> I seems like the latter...
>>>
>> You should let OJB handle the primary (and foreign) keys for you; they
>> end up being the items that OJB is using to track object identity, so
>> the behavior that your seeing is not unexpected (changing the primary
>> key essentially changes the object reference as far as the SQL portion
>> of OJB is concerned).
>
>
> --
> ----------------------------
> Bobby Lawrence
> MIS Application Developer
>
> Jefferson Lab (www.jlab.org)
>
>  Email: robertl@jlab.org
> Office: (757) 269-5818
>  Pager: (757) 584-5818
> ----------------------------
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>


-- 
Carlos Chávez

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


Re: question about collection references...

Posted by Bobby Lawrence <ro...@jlab.org>.
Thanx Robert.
I am letting OJB handle the PK/FK stuff - that is the problem is seems.
I have one object, but I want to change a field...this field is a PK.  I 
want OBJ to update, but it inserts a new one...
--Bobby

Robert r. Sanders wrote:

>
>
> Bobby Lawrence wrote:
>
>> How does OJB handle collection references internally?
>> If I have an object that contains a collection of  other objects, and 
>> I remove one, will OJB remove that same one from the database?
>
>
> If you use that API correctly (see the tutorials), then yes, OJB with 
> track changes to collections, etc... Typical setup is so that if you 
> remove an object from a collection the foriegn key is removed in the 
> DB, but the actual 'object'/row is still there unless you explicitly 
> delete this.  I can't remember off the top of my head, but I believe 
> there is a configuration option (per-collection) to change this so a 
> remove == a db delete.
>
>> Also - if I have a collection that contains only one object and I 
>> change the primary key, does OJB update that object or insert a new one?
>> I seems like the latter...
>>
> You should let OJB handle the primary (and foreign) keys for you; they 
> end up being the items that OJB is using to track object identity, so 
> the behavior that your seeing is not unexpected (changing the primary 
> key essentially changes the object reference as far as the SQL portion 
> of OJB is concerned).


-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------





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


Re: question about collection references...

Posted by "Robert r. Sanders" <ro...@ipov.net>.

Bobby Lawrence wrote:

> How does OJB handle collection references internally?
> If I have an object that contains a collection of  other objects, and 
> I remove one, will OJB remove that same one from the database?

If you use that API correctly (see the tutorials), then yes, OJB with 
track changes to collections, etc... Typical setup is so that if you 
remove an object from a collection the foriegn key is removed in the DB, 
but the actual 'object'/row is still there unless you explicitly delete 
this.  I can't remember off the top of my head, but I believe there is a 
configuration option (per-collection) to change this so a remove == a db 
delete.

> Also - if I have a collection that contains only one object and I 
> change the primary key, does OJB update that object or insert a new one?
> I seems like the latter...
>
You should let OJB handle the primary (and foreign) keys for you; they 
end up being the items that OJB is using to track object identity, so 
the behavior that your seeing is not unexpected (changing the primary 
key essentially changes the object reference as far as the SQL portion 
of OJB is concerned). 

-- 
    Robert r. Sanders
    Chief Technologist
    iPOV
    (334) 821-5412
    www.ipov.net


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