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
On 6/19/06, Dennis Bekkering [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: oracle id in m:n tables
Thanks for the link Tom, that information was exactly what i was looking for. 2006/6/19, Thomas Dudziak [EMAIL PROTECTED]: On 6/19/06, Dennis Bekkering [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- mvg, Dennis