You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Aaron Longwell <li...@newmedialogic.com> on 2003/06/05 17:53:35 UTC

SequenceManagerMySQLImpl

I've been looking in the API for an anwer to my previous question about 
mySQL auto_increment columns. I found the SequenceManagerMySQLImpl class 
and am attempting to implement it.

Here's what I've done:

repository.xml Excerpts: ================================
<sequence-manager 
className="org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl"/>

<class-descriptor class="com.nml.dove.event.EventVO" table="event">
    <field-descriptor name="id" column="ID"
            jdbc-type="BIGINT" primarykey="true"
            autoincrement="true"/>

       .....

</class-descriptor>
================================================

In mySQL Database:
================================================
ID bigint(20) unsigned not null auto_increment,
PRIMARY KEY ('ID')
================================================

When I execute the store command, the record is inserted correctly, but 
I get an error in the afterStore() method:

[org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl]
ERROR: while set field:
object class[ com.nml.dove.event.EventVO
target field: id
target field type: class java.lang.Long
object value class: java.lang.Integer
object value: 3]
[org.apache.ojb.broker.core.PersistenceBrokerImpl]
ERROR: SQLException during SequenceManager.afterStore (for a 
com.nml.dove.event.EventVO):
Error setting field:id in object:com.nml.dove.event.EventVO
Error setting field:id in object:com.nml.dove.event.EventVO

I am submitting the EventVO object to OJB (Persistence Broker API) with 
all fields except ID populated. I am sending ID as a null value. Because 
I am using an auto_increment column in mySQL, I want to store() the 
record without an ID.

One clue to this problem is the target field type/object value class 
discrepancy above:

target field type: class java.lang.Long
object value class: java.lang.Integer

I have no idea where the Integer is coming from. My mySQL column is a 
mediumint, which should correspond to a java Long, right? I have tried 
changing the database table to a bigint with no luck.

It appears that the record goes into the database just fine, but that 
OJB is trying to update my ValueObject (EventVO) ID column with an 
Integer instead of a long.

Is this is bug? Is something wrong with my code?





Re: SequenceManagerMySQLImpl

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi again,

----- Original Message -----
From: "Aaron Longwell" <li...@newmedialogic.com>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Thursday, June 05, 2003 6:26 PM
Subject: Re: SequenceManagerMySQLImpl


> Armin,
>
> Thanks for the quick reply!
>
> Unfortunately, I'm using these mySQL DBs in other apps that aren't
able
> to utilize OJB.
>
> Have you tried the MySQLImpl before?

I think this implementation is a little bit outdated.
SequenceManagerNativeImpl is based on MySQLImpl
implementation.

Please check out CVS head.

The FieldDescriptor for your identity column should
look like.

<field-descriptor
        name="identifier"
        column="NATIVE_ID"
        jdbc-type="BIGINT"
        primarykey="true"
        autoincrement="true"
        access="readonly"
        />
Don't forget 'readonly' access.

> I am thinking something is wrong
> with my setup/code/etc... I am doing something very simple, and I
would
> think even an experimental Class would work for what I'm trying to do.
>
> Is it difficult to create a sequence manager? I don't need anything
> fancy (it doesn't even need to be extents aware).

In theory no! Only implement SequenceManager interface
an set your class in jdbc-connection-descriptor as SM class.
see http://db.apache.org/ojb/sequencemanager.html
section 'How to write my own ....'

regards,
Armin

>
> Thanks,
> Aaron
>
>
> Armin Waibel wrote:
>
> >Hi Aaron,
> >
> >SequenceManagerMySQLImpl is experimental, that's
> >the reason you could not find it in docs
> >http://db.apache.org/ojb/sequencemanager.html
> >
> >In current CVS I add an SequenceManager implementation
> >called SequenceManagerNativeImpl which supports
> >native Identity columns. It's also experimental :-(
> >but seems to work with MySQL.
> >
> >If possible don't use native identity columns ;-)
> >
> >regards,
> >Armin
> >
> >
> >----- Original Message -----
> >From: "Aaron Longwell" <li...@newmedialogic.com>
> >To: "ObjectRelationalBridge User" <oj...@db.apache.org>
> >Sent: Thursday, June 05, 2003 5:53 PM
> >Subject: SequenceManagerMySQLImpl
> >
> >
> >
> >
> >>I've been looking in the API for an anwer to my previous question
> >>
> >>
> >about
> >
> >
> >>mySQL auto_increment columns. I found the SequenceManagerMySQLImpl
> >>
> >>
> >class
> >
> >
> >>and am attempting to implement it.
> >>
> >>Here's what I've done:
> >>
> >>repository.xml Excerpts: ================================
> >><sequence-manager
> >>
> >>
> >>
>
>className="org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl
"
> >/>
> >
> >
> >><class-descriptor class="com.nml.dove.event.EventVO" table="event">
> >>    <field-descriptor name="id" column="ID"
> >>            jdbc-type="BIGINT" primarykey="true"
> >>            autoincrement="true"/>
> >>
> >>       .....
> >>
> >></class-descriptor>
> >>================================================
> >>
> >>In mySQL Database:
> >>================================================
> >>ID bigint(20) unsigned not null auto_increment,
> >>PRIMARY KEY ('ID')
> >>================================================
> >>
> >>When I execute the store command, the record is inserted correctly,
> >>
> >>
> >but
> >
> >
> >>I get an error in the afterStore() method:
> >>
> >>
> >>
> >>
>
>[org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl]
> >
> >
> >>ERROR: while set field:
> >>object class[ com.nml.dove.event.EventVO
> >>target field: id
> >>target field type: class java.lang.Long
> >>object value class: java.lang.Integer
> >>object value: 3]
> >>[org.apache.ojb.broker.core.PersistenceBrokerImpl]
> >>ERROR: SQLException during SequenceManager.afterStore (for a
> >>com.nml.dove.event.EventVO):
> >>Error setting field:id in object:com.nml.dove.event.EventVO
> >>Error setting field:id in object:com.nml.dove.event.EventVO
> >>
> >>I am submitting the EventVO object to OJB (Persistence Broker API)
> >>
> >>
> >with
> >
> >
> >>all fields except ID populated. I am sending ID as a null value.
> >>
> >>
> >Because
> >
> >
> >>I am using an auto_increment column in mySQL, I want to store() the
> >>record without an ID.
> >>
> >>One clue to this problem is the target field type/object value class
> >>discrepancy above:
> >>
> >>target field type: class java.lang.Long
> >>object value class: java.lang.Integer
> >>
> >>I have no idea where the Integer is coming from. My mySQL column is
a
> >>mediumint, which should correspond to a java Long, right? I have
tried
> >>changing the database table to a bigint with no luck.
> >>
> >>It appears that the record goes into the database just fine, but
that
> >>OJB is trying to update my ValueObject (EventVO) ID column with an
> >>Integer instead of a long.
> >>
> >>Is this is bug? Is something wrong with my code?
> >>
> >>
> >>
> >>
> >>
>
>>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>



Re: SequenceManagerMySQLImpl

Posted by Aaron Longwell <li...@newmedialogic.com>.
Armin,

Thanks for the quick reply!

Unfortunately, I'm using these mySQL DBs in other apps that aren't able 
to utilize OJB.

Have you tried the MySQLImpl before? I am thinking something is wrong 
with my setup/code/etc... I am doing something very simple, and I would 
think even an experimental Class would work for what I'm trying to do.

Is it difficult to create a sequence manager? I don't need anything 
fancy (it doesn't even need to be extents aware).

Thanks,
Aaron


Armin Waibel wrote:

>Hi Aaron,
>
>SequenceManagerMySQLImpl is experimental, that's
>the reason you could not find it in docs
>http://db.apache.org/ojb/sequencemanager.html
>
>In current CVS I add an SequenceManager implementation
>called SequenceManagerNativeImpl which supports
>native Identity columns. It's also experimental :-(
>but seems to work with MySQL.
>
>If possible don't use native identity columns ;-)
>
>regards,
>Armin
>
>
>----- Original Message -----
>From: "Aaron Longwell" <li...@newmedialogic.com>
>To: "ObjectRelationalBridge User" <oj...@db.apache.org>
>Sent: Thursday, June 05, 2003 5:53 PM
>Subject: SequenceManagerMySQLImpl
>
>
>  
>
>>I've been looking in the API for an anwer to my previous question
>>    
>>
>about
>  
>
>>mySQL auto_increment columns. I found the SequenceManagerMySQLImpl
>>    
>>
>class
>  
>
>>and am attempting to implement it.
>>
>>Here's what I've done:
>>
>>repository.xml Excerpts: ================================
>><sequence-manager
>>
>>    
>>
>className="org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl"
>/>
>  
>
>><class-descriptor class="com.nml.dove.event.EventVO" table="event">
>>    <field-descriptor name="id" column="ID"
>>            jdbc-type="BIGINT" primarykey="true"
>>            autoincrement="true"/>
>>
>>       .....
>>
>></class-descriptor>
>>================================================
>>
>>In mySQL Database:
>>================================================
>>ID bigint(20) unsigned not null auto_increment,
>>PRIMARY KEY ('ID')
>>================================================
>>
>>When I execute the store command, the record is inserted correctly,
>>    
>>
>but
>  
>
>>I get an error in the afterStore() method:
>>
>>
>>    
>>
>[org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl]
>  
>
>>ERROR: while set field:
>>object class[ com.nml.dove.event.EventVO
>>target field: id
>>target field type: class java.lang.Long
>>object value class: java.lang.Integer
>>object value: 3]
>>[org.apache.ojb.broker.core.PersistenceBrokerImpl]
>>ERROR: SQLException during SequenceManager.afterStore (for a
>>com.nml.dove.event.EventVO):
>>Error setting field:id in object:com.nml.dove.event.EventVO
>>Error setting field:id in object:com.nml.dove.event.EventVO
>>
>>I am submitting the EventVO object to OJB (Persistence Broker API)
>>    
>>
>with
>  
>
>>all fields except ID populated. I am sending ID as a null value.
>>    
>>
>Because
>  
>
>>I am using an auto_increment column in mySQL, I want to store() the
>>record without an ID.
>>
>>One clue to this problem is the target field type/object value class
>>discrepancy above:
>>
>>target field type: class java.lang.Long
>>object value class: java.lang.Integer
>>
>>I have no idea where the Integer is coming from. My mySQL column is a
>>mediumint, which should correspond to a java Long, right? I have tried
>>changing the database table to a bigint with no luck.
>>
>>It appears that the record goes into the database just fine, but that
>>OJB is trying to update my ValueObject (EventVO) ID column with an
>>Integer instead of a long.
>>
>>Is this is bug? Is something wrong with my code?
>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
>
>  
>


Re: SequenceManagerMySQLImpl

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Aaron,

SequenceManagerMySQLImpl is experimental, that's
the reason you could not find it in docs
http://db.apache.org/ojb/sequencemanager.html

In current CVS I add an SequenceManager implementation
called SequenceManagerNativeImpl which supports
native Identity columns. It's also experimental :-(
but seems to work with MySQL.

If possible don't use native identity columns ;-)

regards,
Armin


----- Original Message -----
From: "Aaron Longwell" <li...@newmedialogic.com>
To: "ObjectRelationalBridge User" <oj...@db.apache.org>
Sent: Thursday, June 05, 2003 5:53 PM
Subject: SequenceManagerMySQLImpl


> I've been looking in the API for an anwer to my previous question
about
> mySQL auto_increment columns. I found the SequenceManagerMySQLImpl
class
> and am attempting to implement it.
>
> Here's what I've done:
>
> repository.xml Excerpts: ================================
> <sequence-manager
>
className="org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl"
/>
>
> <class-descriptor class="com.nml.dove.event.EventVO" table="event">
>     <field-descriptor name="id" column="ID"
>             jdbc-type="BIGINT" primarykey="true"
>             autoincrement="true"/>
>
>        .....
>
> </class-descriptor>
> ================================================
>
> In mySQL Database:
> ================================================
> ID bigint(20) unsigned not null auto_increment,
> PRIMARY KEY ('ID')
> ================================================
>
> When I execute the store command, the record is inserted correctly,
but
> I get an error in the afterStore() method:
>
>
[org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl]
> ERROR: while set field:
> object class[ com.nml.dove.event.EventVO
> target field: id
> target field type: class java.lang.Long
> object value class: java.lang.Integer
> object value: 3]
> [org.apache.ojb.broker.core.PersistenceBrokerImpl]
> ERROR: SQLException during SequenceManager.afterStore (for a
> com.nml.dove.event.EventVO):
> Error setting field:id in object:com.nml.dove.event.EventVO
> Error setting field:id in object:com.nml.dove.event.EventVO
>
> I am submitting the EventVO object to OJB (Persistence Broker API)
with
> all fields except ID populated. I am sending ID as a null value.
Because
> I am using an auto_increment column in mySQL, I want to store() the
> record without an ID.
>
> One clue to this problem is the target field type/object value class
> discrepancy above:
>
> target field type: class java.lang.Long
> object value class: java.lang.Integer
>
> I have no idea where the Integer is coming from. My mySQL column is a
> mediumint, which should correspond to a java Long, right? I have tried
> changing the database table to a bigint with no luck.
>
> It appears that the record goes into the database just fine, but that
> OJB is trying to update my ValueObject (EventVO) ID column with an
> Integer instead of a long.
>
> Is this is bug? Is something wrong with my code?
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>