aspose file tools*
The moose likes Object Relational Mapping and the fly likes junk values for the id property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "junk values for the id property " Watch "junk values for the id property " New topic
Author

junk values for the id property

Vishwas T Prasanna
Greenhorn

Joined: Jan 18, 2006
Posts: 8
HIbernate is generating some junk values for the id property plz, can some one help me to sort it out..
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

What do you mean by junk ?
How did you set your id property in hibernate mapping ?


[My Blog]
All roads lead to JavaRanch
Vishwas T Prasanna
Greenhorn

Joined: Jan 18, 2006
Posts: 8
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Jan 18, 2006
Posts: 8
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Jan 18, 2006
Posts: 8
I am using net.sf.hibernate.dialect.Oracle9Dialect dialect
and jdbc driver ojdbc14.jar.
Vishwas T Prasanna
Greenhorn

Joined: Jan 18, 2006
Posts: 8
driver class is oracle.jdbc.driver.OracleDriver
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Jan 18, 2006
Posts: 8
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

Try to download a newer driver then

http://www.hibernate.org/80.html
Vishwas T Prasanna
Greenhorn

Joined: Jan 18, 2006
Posts: 8
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

Glad it helped.
Have a nice weekend.
 
wood burning stoves
 
subject: junk values for the id property