Hi Tom,

Thomas Dudziak wrote:

On Mon, 5 Apr 2004, Guido Beutler wrote:



Hi,

I use OJB RC6 and DB2. I want to insert a abject into a table with a sequence.
I took the settings from documentation and added to database.xml :


<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
<attribute attribute-name="autoNaming" attribute-value="true"/>
</sequence-manager>


and at the class descriptor :

     primarykey="true"
     autoincrement="true"
     sequence-name="TEST_SEQUENCE"

OJB still tries to insert the pk field to which causes a SQL exception. DB2 expects that the field is not used
at the insert statement. DB2 then generates the pk value itself.
I also tried to leave the sequence name open but this had no effect.
What am I doing wrong?



How is the field defined in the database ?


I'm no expert on sequence managers, but as far as I understand them, the
difference between SequenceManagerNextValImpl and
SequenceManagerNativeImpl is that for the former, in the database the
field is defined as a normal field (no autoincrement/identity
setting) whereas for the native impl the database increments the field
automatically (without OJB intervening, thus you should have
access='readonly' in this case).

Tom


Readonly was a usefull hint. I removed the sequence name at the class descriptor and added a
readonly attribute. I still use nextVal sequence manager. This now works for me.
Thanks !!


best regards,

Guido



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to