Hi John,

I'm using the xdoclet module and when I specify autoincrement=true in my class I get
[ojbdoclet] (XDocletMain.start 54 ) <<The value 'true' specified for parameter 'autoincrement' of ojb.field tag in id field of EnrollmentAction class is not valid. Valid values for this tag are: {none,ojb,database}.>>
[ojbdoclet] D:\eclipse-workspace\unisg.lms-integrator\build.xml:79: XDoclet failed.


When I set it to database the autoincrement value isn't generated at all. I'm using OJB 1.0 RC6 and the xdoclet jars that come with it.

Anyway even if I try to set it to true or database manually in the repository file it still generates the same error.

Any clues?

Sebastian

McCaffrey, John G. wrote:

try setting autoincrement=true on the ID mapping

-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] Behalf Of Sebastian
Sent: Wednesday, May 19, 2004 1:10 PM
To: [EMAIL PROTECTED]
Subject: MySQL + Native Autoincrement


Hi,
I'm trying to create a record on a table where an autoincrement for the id column is performed by the database. Whatever I do I always get:


org.apache.ojb.broker.KeyConstraintViolatedException: SQL failure while insert object data for class EnrollmentAction, PK of the given object is [ id=0], object was [EMAIL PROTECTED], exception message is [Duplicate key or integrity constraint violation, message from server: "Duplicate entry '0' for key 1"]
at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImp
l.java:238)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBroker
Impl.java:1620)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl
.java:1537)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl
.java:683)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersi
stenceBroker.java:174)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersi
stenceBroker.java:174)
at Integrator.main(LmsIntegrator.java:47)
Caused by: java.sql.SQLException: Duplicate key or integrity constraint violation, message from server: "Duplicate entry '0' for key 1"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1962)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1163)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1257)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2242)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1677)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1524)
at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImp
l.java:197)
... 6 more


======================================================

Here is the id field descriptor I'm using:

<class-descriptor class="EnrollmentAction" table="ENROLLMENTS">
  <field-descriptor
   name="id"
   column="id"
   jdbc-type="BIGINT"
   primarykey="true"
   nullable="false"
   access="readonly"
  >
  </field-descriptor>

   ...

</class-descriptor>

======================================================

The sequence-manager is set to org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl

How can I suppress that OJB tries to set ID to 0 in the SQL INSERT statement?

Thanks in advance!


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


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



Reply via email to