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 Dennis Bekkering <dj...@gmail.com> on 2006/06/19 13:03:18 UTC

oracle id in m:n tables

Hello All,

When i add a record to a collection that is of type many 2 many the
following sql is executed

INSERT INTO m2m_196 (ruleValueListId,ruleValueId) VALUES (?,?) , the id
field is not specified in the query but the table has such a field and
therefore oracle complains about the fact that the id is not there. I know
that i could do without an id field and use a composit id but i rather move
on  without having to change all my tables. I dont believe i can let oracle
asign id's automatically like on mysql. Is there a solution to this problem?

Cheers,
Dennis

Re: oracle id in m:n tables

Posted by Dennis Bekkering <dj...@gmail.com>.
Thanks for the link Tom, that information was exactly what i was looking
for.

2006/6/19, Thomas Dudziak <to...@gmail.com>:
>
> On 6/19/06, Dennis Bekkering <dj...@gmail.com> wrote:
>
> > When i add a record to a collection that is of type many 2 many the
> > following sql is executed
> >
> > INSERT INTO m2m_196 (ruleValueListId,ruleValueId) VALUES (?,?) , the id
> > field is not specified in the query but the table has such a field and
> > therefore oracle complains about the fact that the id is not there. I
> know
> > that i could do without an id field and use a composit id but i rather
> move
> > on  without having to change all my tables. I dont believe i can let
> oracle
> > asign id's automatically like on mysql. Is there a solution to this
> problem?
>
> From what I gather Oracle complains about a missing primary key in the
> table m2m_196, right ? If that's the case, then there are two easy
> solutions that I can think of:
>
> * If the pair (ruleValueListId,ruleValueId) is unique in the table,
> then you can generate a composite primary key with these two columns.
>
> * Otherwise, you should define a sequence and add a new column to the
> table for the primary key. Something like this:
>
>
> http://www.lifeaftercoffee.com/2006/02/17/how-to-create-auto-increment-columns-in-oracle/
>
> In this case, OJB will not have anything to do with the primary key of
> the m:n table.
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>


-- 
mvg,
Dennis

Re: oracle id in m:n tables

Posted by Thomas Dudziak <to...@gmail.com>.
On 6/19/06, Dennis Bekkering <dj...@gmail.com> wrote:

> When i add a record to a collection that is of type many 2 many the
> following sql is executed
>
> INSERT INTO m2m_196 (ruleValueListId,ruleValueId) VALUES (?,?) , the id
> field is not specified in the query but the table has such a field and
> therefore oracle complains about the fact that the id is not there. I know
> that i could do without an id field and use a composit id but i rather move
> on  without having to change all my tables. I dont believe i can let oracle
> asign id's automatically like on mysql. Is there a solution to this problem?

>From what I gather Oracle complains about a missing primary key in the
table m2m_196, right ? If that's the case, then there are two easy
solutions that I can think of:

* If the pair (ruleValueListId,ruleValueId) is unique in the table,
then you can generate a composite primary key with these two columns.

* Otherwise, you should define a sequence and add a new column to the
table for the primary key. Something like this:

http://www.lifeaftercoffee.com/2006/02/17/how-to-create-auto-increment-columns-in-oracle/

In this case, OJB will not have anything to do with the primary key of
the m:n table.

Tom

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