This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Primary key generated as 5000000000006877 when generator class used is native Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Primary key generated as 5000000000006877 when generator class used is native" Watch "Primary key generated as 5000000000006877 when generator class used is native" New topic
Author

Primary key generated as 5000000000006877 when generator class used is native

Anvi Chavda
Greenhorn

Joined: Oct 28, 2009
Posts: 2
Hi,
I have table named remitter with primary key column as remitterId. The last entry in the table was with the remitterId as 6988(approx). On generation of the new remitter from the application it starts entering the row with remitterId as 500000000006877, which is a long digit and so application throws NumberformatException. While digging more in to it I found that generator class is native.

I have two questions here:
1. Why all of sudden this behaviour aroused?
2. how can I add the entries in the table once again to normal four digit?

I mean do i have to restart the application server or should make any changes in the database?

I am using sybase database.

Regards
Achavda
Anantha Sharma
Ranch Hand

Joined: Sep 01, 2010
Posts: 43

you should check your sequence generator (Oracle) or run DBCC on MS SQL / MySql servers to find out what is the next PK value.. the problem should be there as your generator class is set to native (meaning that the db will take care of the id assignment).

Anvi Chavda
Greenhorn

Joined: Oct 28, 2009
Posts: 2
Thanks Anantha,

Can you give the solution for the Sybase database. I am able to trace the sysindexed table and when searched with the primaryKey (pkREMIITER) of Remitter table, found the following result
id = 2029218548
and status = 2050
Dont know what to do with these details. Will changing any of the columns in sysindexes table help ?
Anantha Sharma
Ranch Hand

Joined: Sep 01, 2010
Posts: 43

not sure about sybase, with MS SQL server we have the DBCC command which can reseed a auto increment field...

Sybase has the dbcc command but no the identity reset option in it... i'm sure there is a way to reset an auto increment field (just need to search the net for it).

sorry i couldn't be of much help...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Primary key generated as 5000000000006877 when generator class used is native
 
Similar Threads
is ID tag in hibernate map.xml is compulsory?
problem with Primary Key/ Generator class [Hibernate]
which generator type to use..?
Hibernate Mapping problem because no primary key in database
why my oracle sequence id increases by 2 when I use hibernate to insert