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 Marcus Woinke <ma...@woinke.de> on 2003/12/24 09:57:47 UTC
Primary key problem
Hello!
Is it possible to store/retrieve objects to a table without primary key
(I know it is a bad table design, but to add a PK in production is
impossible in the moment).
There have to be a primary key declaration in the repository for each
table. I've tried a Oracle 'ROWID' with anonymous access, but this
don't work for storing.
Table 1 (main table):
CST_ID (PK)
some more fields ...
Table 2:
OTC_CST_ID (no PK !!, not unique!!, references CST_ID in Table 1)
some more fields...
How to map this 1:n relationship with OJB?
Please help. We're stuck.
Thanks in advance.
Bye, Marcus Woinke
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Primary key problem
Posted by Marcus Woinke <ma...@woinke.de>.
Jakob Braeuchi wrote:
>hi marcus,
>
>the relationship definition should be no problem because you have a pk
>in the main table and a foreign key (OTC_CST_ID) in table2.
>but ojb needs at least one pk field or you'll get a
>ClassNotPersistenceCapableException in Identity. what about using the
>timestamp as pk ?
>
>
>
Ok, we try it.
>jakob
>
>Marcus Woinke wrote:
>
>
>
Have a nice X-Mas.
bye, Marcus
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Primary key problem
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi marcus,
the relationship definition should be no problem because you have a pk
in the main table and a foreign key (OTC_CST_ID) in table2.
but ojb needs at least one pk field or you'll get a
ClassNotPersistenceCapableException in Identity. what about using the
timestamp as pk ?
jakob
Marcus Woinke wrote:
> Jakob Braeuchi wrote:
>
>> hi marcus,
>>
>>
>>
> Hello Jakob,
>
>> ojb needs pk to identify objects in the cache etc. i can't believe that
>>
> I know, but ...
>
>> you have no unique combination of columns in your table.
>>
>>
>>
> When I declare all fields as PK, then I think we have uniqueness
> (timestamp field).
> Is this your solution? May I overlook something?
>
> Some more explanation:
> For one entry in table 1 we have zero or n entries in table 2
> (collection reference) referenced through CST_ID<-OTC_CST_ID relationship.
> CST_ID is PK of the main table, but OTC_CST_ID is not a PK. Table 2 has
> no constraints at all.
>
> When we fetch an entry of table 1, we want to get a collection of all
> associated entries of table 2.
> For storing we generate a collection of objects of table 2 and when we
> store a object of table 1, they should be stored too.
>
> With other tables we use this mapping with success (they have all PK!),
> but in this case the database design is bad
> and the referenced table has no PK.
>
> Not easy to explain.
>
> Thanks for your fast answer.
>
> Bye, Marcus
>
>> jakob
>>
>> Marcus Woinke wrote:
>>
>>
>>> Hello!
>>>
>>> Is it possible to store/retrieve objects to a table without primary
>>> key (I know it is a bad table design, but to add a PK in production
>>> is impossible in the moment).
>>> There have to be a primary key declaration in the repository for each
>>> table. I've tried a Oracle 'ROWID' with anonymous access, but this
>>> don't work for storing.
>>>
>>> Table 1 (main table):
>>> CST_ID (PK)
>>> some more fields ...
>>>
>>> Table 2:
>>> OTC_CST_ID (no PK !!, not unique!!, references CST_ID in Table 1)
>>> some more fields...
>>>
>>> How to map this 1:n relationship with OJB?
>>>
>>>
>>>
>>> Please help. We're stuck.
>>>
>>> Thanks in advance.
>>> Bye, Marcus Woinke
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Primary key problem
Posted by Marcus Woinke <ma...@woinke.de>.
Jakob Braeuchi wrote:
>hi marcus,
>
>
>
Hello Jakob,
>ojb needs pk to identify objects in the cache etc. i can't believe that
>
>
I know, but ...
>you have no unique combination of columns in your table.
>
>
>
When I declare all fields as PK, then I think we have uniqueness
(timestamp field).
Is this your solution? May I overlook something?
Some more explanation:
For one entry in table 1 we have zero or n entries in table 2
(collection reference) referenced through CST_ID<-OTC_CST_ID relationship.
CST_ID is PK of the main table, but OTC_CST_ID is not a PK. Table 2 has
no constraints at all.
When we fetch an entry of table 1, we want to get a collection of all
associated entries of table 2.
For storing we generate a collection of objects of table 2 and when we
store a object of table 1, they should be stored too.
With other tables we use this mapping with success (they have all PK!),
but in this case the database design is bad
and the referenced table has no PK.
Not easy to explain.
Thanks for your fast answer.
Bye, Marcus
>jakob
>
>Marcus Woinke wrote:
>
>
>>Hello!
>>
>>Is it possible to store/retrieve objects to a table without primary key
>>(I know it is a bad table design, but to add a PK in production is
>>impossible in the moment).
>>There have to be a primary key declaration in the repository for each
>>table. I've tried a Oracle 'ROWID' with anonymous access, but this
>>don't work for storing.
>>
>>Table 1 (main table):
>>CST_ID (PK)
>>some more fields ...
>>
>>Table 2:
>>OTC_CST_ID (no PK !!, not unique!!, references CST_ID in Table 1)
>>some more fields...
>>
>>How to map this 1:n relationship with OJB?
>>
>>
>>
>>Please help. We're stuck.
>>
>>Thanks in advance.
>>Bye, Marcus Woinke
>>
>>---------------------------------------------------------------------
>>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: Primary key problem
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi marcus,
ojb needs pk to identify objects in the cache etc. i can't believe that
you have no unique combination of columns in your table.
jakob
Marcus Woinke wrote:
> Hello!
>
> Is it possible to store/retrieve objects to a table without primary key
> (I know it is a bad table design, but to add a PK in production is
> impossible in the moment).
> There have to be a primary key declaration in the repository for each
> table. I've tried a Oracle 'ROWID' with anonymous access, but this
> don't work for storing.
>
> Table 1 (main table):
> CST_ID (PK)
> some more fields ...
>
> Table 2:
> OTC_CST_ID (no PK !!, not unique!!, references CST_ID in Table 1)
> some more fields...
>
> How to map this 1:n relationship with OJB?
>
>
>
> Please help. We're stuck.
>
> Thanks in advance.
> Bye, Marcus Woinke
>
> ---------------------------------------------------------------------
> 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