On Tue, 6 Apr 2004, Guido Beutler wrote: > Hi Armin, > > Armin Waibel wrote: > > > Hi, > > > > Guido Beutler wrote: > > > >> NextValImpl is ok for me. There is a database sequence at the pk > >> column which caused my problem. > >> After setting the readonly attribute for the primary key column at > >> the repository everything worked fine. > > > > > > hmm, this shouldn't work. If you set readonly the PK field will be not > > passed to the DB (and the PK will not be set). This only works for > > identity columns. > > ?? > The database generates the pk value and permits that you can pass a pk > value at a insert statement. > Every insert statement, which contains the pk columns, causes a SQL > Exception. > This is the reason, why read-only works, I think.
If the database (as opposed to OJB) automatically creates the pk value upon insertion of a new row, then you should indeed use the NativeImpl as this is what it's designed for. You should be aware that db-generated pk-values do not work in OJB when you have an inheritance hierarchy that is mapped onto multiple tables, e.g. B extends A and A mapped to TABLE_A, B mapped to TABLE_B. In this case you should let OJB insert the pk values using your sequence and the NextValImpl. Otherwise you get problems for instance when trying to retrieve all objects of type A. Tom --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
