On Wed, 14 Apr 2004, Stijn de Witt wrote:

> Now I see the insert for address passing an id, which looks wrong to me
> (since it is an auto-increment column), but it works ok. However, the
> generated id is never fetched from the database, so it is no wonder that the
> personId and addressId fields in the link table bit_PersonAddress get set to
> 0!

If you use native autoincrement (i.e. the column is specififed as
autoincrement in MySQL), then you should declare this field as
access='readonly' in the repository descriptor (so that OJB does not try
to set the field), and use the SequenceManagerNativeImpl (for MySql at
least).
 
> Is it recommended to use mysql's auto-increment with OJB? If so, what am I
> doing wrong? If not, what other approach might you suggest?

Usually you shouldn't. It is often better to let OJB generate the primary
key values. The major exception to this rule is when you have other
non-OJB apps inserting data into these tables in which case you need
database-based primarykey generation (which in MySql 3 and 4 means
autoincrement columns).
For details on the sequence managers see
http://db.apache.org/ojb/sequencemanager.html.

BTW, you should perhaps update the OJB xdoclet module from CVS
(http://cvs.apache.org/viewcvs/db-ojb/), files xdoclet-1.2.jar,
xdoclet-ojb-module-1.2.jar, xjavadoc-1.0.2.jar in the lib folder and
xdoclet.xml in the xdocs folder, because I've made some changes to the
handling of autoincrement.

Tom


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

Reply via email to