Nilesh, if you are still having difficulty, it is time to step through the code with a debugger, like Eclipse. But first, you'll need to get the OJB source code and compile it (at least org/apache/ojb/broker/util/sequence/SequenceManagerNativeImpl) in your IDE. This because rc5 and rc6 are not compiled with debug on. The methods you want to focus on are afterStore() and getLastInsert().


If you do not get to afterStore, get org/apache/ojb/broker/accesslayer/JdbcAccessImpl and step through executeInsert(). It would seem your metadata is incorrect, or repository.xml is not setup for NativeImpl.

If you're getting this fa...In SequenceManagerNativeImpl.getLastInsert(), step into lastInsertSelect() and watch with particular detail the SQL statement returned from the platform class. This is the heart of the code that gets the PK value assigned by your DB. It was also the source of all my problems with MS SQL Server!

Good luck and let us know how you fare.




From: Armin Waibel <[EMAIL PROTECTED]>
Reply-To: "OJB Users List" <[EMAIL PROTECTED]>
To: OJB Users List <[EMAIL PROTECTED]>
Subject: Re: auto increment not working
Date: Sat, 24 Apr 2004 10:31:35 +0200

Hi Nilesh,

    <class-descriptor
> >class="com.haystack.emailmarketingchoice.member.MemberVO"
> >table="tblMember">
> >
> >        <field-descriptor id="1" name="memberId" column="member_id"
> >jdbc-type="BIGINT"  primarykey="true" autoincrement="true"
> >access="readonly" />
> >         ------------
> >         ------------
> >     </class-descriptor>

As Glenn said your mapping looks fine. There is a test case in OJB test suite called ....broker.sequence.NativeIdentifierTest. This test is valid for Hsql and MySQL. I don't use MySQL personally, but some other developer use it and test seems to pass.
Only problem I know about is with old versions of MySQL, seems they don't support the used query to get the last inserted id (in that case you have to patch the PlatformMySQLImpl class).


>>>I am using MySQL in which I have also used the auto-increment constraint
>>>for the Primarykey ( bigint(20) )


I don't know the best setting for "member_id" column, but shouldn't it be NATIVE_ID int(20) or something else instead bigint(20) (sorry if I tell nonsense)?

regards,
Armin

Nilesh wrote:


Thanks Glenn,
Yes I am using OJB rc6. And I have also tried without
using any sequence manager. Do I neeed to create my own sequence manager.
How will it help and how do I do that ? Please tell me if you have any idea.


Thanks again.


Regards, Nilesh.






----- Original Message ----- From: "Glenn Barnard" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, April 23, 2004 8:56 PM Subject: RE: auto increment not working



Your settings look good. I use this technique with MS SQL Server and all

is


working well. Please note which version of OJB you're using. Hopefully,

its


rc6!


From: "Nilesh" <[EMAIL PROTECTED]>
Reply-To: "OJB Users List" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
CC: <[EMAIL PROTECTED]>
Subject: auto increment not working
Date: Sun, 22 Feb 2004 19:40:34 +0530

In my OJB (using  PersistenceBroker ) application auto-increment is not
working.

I am using MySQL in which I have also used the auto-increment constraint
for the Primarykey ( bigint(20) )



For my database definition i have used the "SequenceManagerNativeImpl"


<sequence-manager

className="org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl">


           <attribute attribute-name="autoNaming"
attribute-value="true"/>
</sequence-manager>


also in the mapping file i have


   <class-descriptor
class="com.haystack.emailmarketingchoice.member.MemberVO"
table="tblMember">

      <field-descriptor id="1" name="memberId" column="member_id"
jdbc-type="BIGINT"  primarykey="true" autoincrement="true"
access="readonly" />
       ------------
       ------------
   </class-descriptor>

i have also tried without the --> access="readonly"

but it generates a new 20 digit "auto-increment" number only for the
first insert, for the subsequent inserts it generates the same number and

a


Duplicate Entry error arises.

I have also tried the following sequence managers

SequenceManagerMySQLImpl
SequenceManagerSeqHiLoImpl

with and without these attributes
 <attribute attribute-name="grabSize" attribute-value="5" />
 <attribute attribute-name="globalSequenceId" attribute-value="true"/>
<attribute attribute-name="globalSequenceStart"

attribute-value="10000"/>




But ALL Failed.
Have any one of you tried this. Please let me know.
Thanks in advance for your interest in my problem.

Regards,
Arjun.







_________________________________________________________________ From must-see cities to the best beaches, plan a getaway with the Spring Travel Guide! http://special.msn.com/local/springtravel.armx


--------------------------------------------------------------------- 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]




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


_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar � get it now! http://toolbar.msn.com/go/onm00200415ave/direct/01/



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



Reply via email to