• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

junk values for the id property

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HIbernate is generating some junk values for the id property plz, can some one help me to sort it out..
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by junk ?
How did you set your id property in hibernate mapping ?
 
Vishwas T Prasanna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i save the object and see in the oracle 9i database the id column has these values.. ( 9.900E+123 , -0.370E-28 ) . I am using a oracle sequence (1- 999999999...), and the current sequence value in the database in 345.
Hibernate mapping for id column is as given below..

<class name="userSessionBO" table="USER_SESSIONS" dynamic-update="true" dynamic-insert="true" select-before-update="true">

<id name="id" column="id" type="integer" unsaved-value="null">
<generator class="sequence">
<param name="sequence">USER_SESSIONS_SEQ</param>
</generator>
</id>
....

</calss>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean that "select id from user_sessions" give you weird values ?
Check the return value in SQL:
select USER_SESSIONS_SEQ.nextval from dual;

Moreover, what is the type of your id in userSessionBO ?
 
Vishwas T Prasanna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The query
select USER_SESSIONS_SEQ.nextval from dual;
result is proper..

I am using "private Integer id;" in userSessionsBO .

This is code which is saving the userSessionsBO

1. serviceImpl.beginTransaction();
2. sessionBO.setCreatedOn(new Date());
3. sessionBO.setCreatedBy(personBO.getAccountName());
4. serviceImpl.getSession().save(sessionBO);
5. serviceImpl.commitTransaction();

at line 1 i checked that id is null and then i put a break point at line 4 and checked the id value after save. It is same value from the query " select USER_SESSIONS_SEQ.nextval from dual; " but after committing when i check in the database the id value is different.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is strange indeed.
What version of JDBC are you using ?
Versions prior to 9.2.0.3 for Oracle 9 are not recommended (buggy).

Another thing, which dialect are you using in your config file ?
[ January 26, 2006: Message edited by: Satou kurinosuke ]
 
Vishwas T Prasanna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using net.sf.hibernate.dialect.Oracle9Dialect dialect
and jdbc driver ojdbc14.jar.
 
Vishwas T Prasanna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
driver class is oracle.jdbc.driver.OracleDriver
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The version is probably in the META-INF/MANIFEST.MF, in the jar file.
Could you please check it ?
If it's under 9.2.0.3, try to download a new driver.

I'm using Integer sequences too with Oracle 8. No problem so far.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That does not help, but I found a similar problem here :

>The value of the sequence is 1931 and after save if I do a panelBO.getId(), it returns 1931... all seems ok but in database its value is 1,3363E-56

http://forums.hibernate.org/viewtopic.php?p=2212492&highlight=&sid=9c28d1e16581e3ab4a9e22f2f8644432
 
Vishwas T Prasanna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on the comments sent by u.

This is information u asked
jdbc driver racle JDBC Driver version - 9.0.2.0.0
oracle version :
Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
With the Partitioning option
JServer Release 9.0.1.1.1 - Production
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to download a newer driver then

http://www.hibernate.org/80.html
 
Vishwas T Prasanna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
haeee it worked... i changed the driver from ojdbc14.jar to classes12.jar.. and its working.

Thanks a lot... With out u i would have wasted another week ...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad it helped.
Have a nice weekend.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic