The mapping part ist as follows:
<class-descriptor class="ch.eugster.pos.db.ProductGroup"
table="pos_product_group" isolation-level="read-uncommitted"
accept-locks="true" refresh="false">
<field-descriptor name="id" column="id" jdbc-type="BIGINT" primarykey="true"
indexed="true" access="readwrite" autoincrement="true" nullable="true"
locking="false" update-lock="true" default-fetch="false" />
<field-descriptor name="timestamp" column="timestamp" jdbc-type="TIMESTAMP"
primarykey="false" nullable="true" indexed="false" autoincrement="false"
locking="false" update-lock="true" default-fetch="false" access="readwrite" />
<field-descriptor name="deleted" column="deleted" jdbc-type="BIT"
primarykey="false" nullable="true" indexed="false" autoincrement="false"
locking="false" update-lock="true" default-fetch="false" access="readwrite" />
<field-descriptor name="defaultGroup" column="default_group" jdbc-type="BIT"
primarykey="false" nullable="true" indexed="false" autoincrement="false"
locking="false" update-lock="true" default-fetch="false" access="readwrite" />
<field-descriptor name="galileoId" column="galileo_id" jdbc-type="VARCHAR"
length="3" primarykey="false" nullable="true" indexed="false"
autoincrement="false" locking="false" update-lock="true" default-fetch="false"
access="readwrite" />
<field-descriptor name="defaultTaxId" column="default_tax_id"
jdbc-type="BIGINT" primarykey="false" nullable="true" indexed="false"
autoincrement="false" locking="false" update-lock="true" default-fetch="false"
access="readwrite" />
<field-descriptor name="shortname" column="shortname" jdbc-type="VARCHAR"
length="50" primarykey="false" nullable="true" indexed="false"
autoincrement="false" locking="false" update-lock="true" default-fetch="false"
access="readwrite" />
<field-descriptor name="name" column="name" jdbc-type="VARCHAR" length="255"
primarykey="false" nullable="true" indexed="false" autoincrement="false"
locking="false" update-lock="true" default-fetch="false" access="readwrite" />
<field-descriptor name="quantityProposal" column="quantity_proposal"
jdbc-type="INTEGER" primarykey="false" nullable="true" indexed="false"
autoincrement="false" locking="false" update-lock="true" default-fetch="false"
access="readwrite" />
<field-descriptor name="priceProposal" column="price_proposal"
jdbc-type="DOUBLE" primarykey="false" nullable="true" indexed="false"
autoincrement="false" locking="false" update-lock="true" default-fetch="false"
access="readwrite" />
<field-descriptor name="optCodeProposal" column="opt_code_proposal"
jdbc-type="VARCHAR" length="1" primarykey="false" nullable="true"
indexed="false" autoincrement="false" locking="false" update-lock="true"
default-fetch="false" access="readwrite" />
<field-descriptor name="account" column="account" jdbc-type="VARCHAR"
length="100" primarykey="false" nullable="true" indexed="false"
autoincrement="false" locking="false" update-lock="true" default-fetch="false"
access="readwrite" />
<field-descriptor name="isIncome" column="is_income" jdbc-type="BIT"
primarykey="false" nullable="true" indexed="false" autoincrement="false"
locking="false" update-lock="true" default-fetch="false" access="readwrite" />
<field-descriptor name="isExpense" column="is_expense" jdbc-type="BIT"
primarykey="false" nullable="true" indexed="false" autoincrement="false"
locking="false" update-lock="true" default-fetch="false" access="readwrite" />
<field-descriptor name="modified" column="modified" jdbc-type="BIT"
primarykey="false" nullable="false" indexed="false" autoincrement="false"
locking="false" update-lock="true" default-fetch="false" access="readwrite" />
<field-descriptor name="type" column="type" jdbc-type="INTEGER"
primarykey="false" nullable="false" indexed="false" autoincrement="false"
locking="false" update-lock="true" default-fetch="false" access="readwrite" />
<field-descriptor name="exportId" column="export_id" jdbc-type="VARCHAR"
length="10" primarykey="false" nullable="false" indexed="false"
autoincrement="false" locking="false" update-lock="true" default-fetch="false"
access="readwrite" />
<reference-descriptor name="defaultTax" class-ref="ch.eugster.pos.db.Tax"
proxy="false" refresh="false" auto-retrieve="true" auto-update="false"
auto-delete="false" otm-dependent="false">
<foreignkey field-ref="defaultTaxId" />
</reference-descriptor>
</class-descriptor>
(but the same problem is for every class/table)
the code saving a new Object is:
public DBResult store(Connection connection) {
PersistenceBroker broker = connection.getBroker();
DBResult result = new DBResult();
boolean isMyTransaction = !broker.isInTransaction();
try {
if (isMyTransaction) {
broker.beginTransaction();
}
broker.store(this);
if (isMyTransaction) {
broker.commitTransaction();
}
}
catch (PersistenceBrokerException e) {
if (isMyTransaction) {
broker.abortTransaction();
}
if (e instanceof ClassNotPersistenceCapableException) {
testSwitchDatabase();
}
else if (isMyTransaction) {
result = describeError(e);
if (e instanceof PersistenceBrokerSQLException)
{
PersistenceBrokerSQLException psqle =
(PersistenceBrokerSQLException) e;
if (psqle.getSourceException()
instanceof SQLException) {
SQLException sqle =
(SQLException) psqle.getSourceException();
//result = describeError(sqle);
// if
(sqle.getSQLState().equals("08S01")) { //$NON-NLS-1$
testSwitchDatabase();
// }
}
}
}
}
return result;
}
and the code that sets the connection is:
public void setConnection(JdbcConnectionDescriptor cd, Element el) {
cd.setJcdAlias(el.getAttributeValue("jcd-alias")); //$NON-NLS-1$
cd.setDefaultConnection(Boolean.getBoolean(el.getAttributeValue("default-connection")));
//$NON-NLS-1$
cd.setDbms(el.getAttributeValue("platform")); //$NON-NLS-1$
cd.setJdbcLevel(el.getAttributeValue("jdbc-level"));
//$NON-NLS-1$
cd.setDriver(el.getAttributeValue("driver")); //$NON-NLS-1$
cd.setProtocol(el.getAttributeValue("protocol")); //$NON-NLS-1$
cd.setSubProtocol(el.getAttributeValue("subprotocol"));
//$NON-NLS-1$
StringBuffer sb = new StringBuffer("//"); //$NON-NLS-1$
sb.append(el.getAttributeValue("host")); //$NON-NLS-1$
sb.append(":"); //$NON-NLS-1$
sb.append(el.getAttributeValue("port")); //$NON-NLS-1$
if (el.getAttributeValue("database").length() > 0) {
//$NON-NLS-1$
sb.append("/"); //$NON-NLS-1$
sb.append(el.getAttributeValue("database"));
//$NON-NLS-1$
}
sb.append(el.getAttributeValue("options")); //$NON-NLS-1$
// cd.addAttribute("autoReconnect", "true");
cd.setDbAlias(sb.toString());
cd.setUserName(el.getAttributeValue("username")); //$NON-NLS-1$
cd.setPassWord(el.getAttributeValue("password")); //$NON-NLS-1$
cd.setBatchMode(Boolean.getBoolean(el.getAttributeValue("batch-mode")));
//$NON-NLS-1$
cd.setUseAutoCommit(Integer.parseInt(el.getAttributeValue("use-auto-commit")));
//$NON-NLS-1$
ConnectionPoolDescriptor cpd = cd.getConnectionPoolDescriptor();
SequenceDescriptor sd = new SequenceDescriptor(cd);
sd.setSequenceManagerClass(org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl.class);
sd.addAttribute("grabSize", "20");
}
Thanks
Christian
-------- Original-Nachricht --------
> Datum: Fri, 28 Sep 2007 17:23:29 +0200
> Von: Armin Waibel <[EMAIL PROTECTED]>
> An: OJB Users List <[email protected]>
> Betreff: Re: Different behaviour of SequenceManager in rc5 and 1.0.1
> Hi Christian,
>
> Christian Eugster wrote:
> > Hi,
> >
> > In my program I updated ojb from 1.0.rc5 to 1.0.1. When I store a new
> > record the sequence manager does not assign a value to my primary key
> > field (autoincrement=true). With 1.0.rc5 it did it (and does it) with
> > no problem. With 1.0.4 too there is no assigning to the autoincrement
> > field. I use
> > org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl as
> > Sequence Manager.
> >
> > Has anybody any suggestion, what i can do?
> >
>
> Please post the mapping (class-descriptor) of the related class and a
> code snip or pseudo code of the related source code (insert of the
> object).
>
> regards,
> Armin
>
> > Thanks a lot!
> >
> > Christian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
****************************
Christian Eugster
Grissian Widum 14
I-39010 Tisens
--------------------------------------
Handy Schweiz: 0041 79 594 85 45
Handy Italia: 0039 333 888 77 64
Email: [EMAIL PROTECTED]
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]