-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Problem with DoubleType in jUnit
PostPosted: Fri Jan 09, 2004 12:47 am 
Beginner
Beginner

Joined: Tue Dec 30, 2003 1:51 pm
Posts: 49
Location: Michigan, USA
I am having a problem with jUnit reading a double type in a testcase the output is:

Code:
[junit] ------------- Standard Error -----------------
[junit] net.sf.hibernate.MappingException: Bad identifier type: net.sf.hibernate.type.DoubleType
[junit]     at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:655)
[junit]     at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:741)
[junit]     at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41)
[junit]     at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136)
[junit]     at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
[junit]     at omni.test.HibernateTestCase.buildSessionFactory(HibernateTestCase.java:104)
[junit]     at omni.test.HibernateTestCase.setUp(HibernateTestCase.java:116)
[junit]     at omni.test.UserBeanTest.setUp(UserBeanTest.java:52)
[junit]     at junit.framework.TestCase.runBare(TestCase.java:125)
[junit]     at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit]     at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit]     at junit.framework.TestResult.run(TestResult.java:109)
[junit]     at junit.framework.TestCase.run(TestCase.java:118)
[junit]     at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit]     at junit.framework.TestSuite.run(TestSuite.java:203)
[junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325)
[junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:536)


i am using a double for my userId, which may be overkill. however, since i am using schemaexport shouldn't hibernate understand this. i have selected the correct dialet for MySQL.

i've done a search for this and nothing is coming up. has this happened to anyone else? any ideas?

thanks,

jason


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2004 12:56 am 
Beginner
Beginner

Joined: Tue Dec 30, 2003 1:51 pm
Posts: 49
Location: Michigan, USA
i just tried the same test with all id's set as int's and it worked. very weird, i double checked (no pun intended) the docs and there is nothing about any type of special calls for a double.

can someone let me know if this is correct? should i jira it?

jason


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2004 8:18 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Post your schema.



Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2004 11:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Only certain types support the unsaved-value attribute - basically, only those types that are sensible for use as an identifier. Double is an absolutely nonsensical identifier type. Computers do not implement comparison of floating point values correctly. Never, ever write code like this:

if ( fooDouble==barDouble ) { .... }


since it is completely broken.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 1:07 pm 
Beginner
Beginner

Joined: Tue Dec 30, 2003 1:51 pm
Posts: 49
Location: Michigan, USA
thanks gavin,
i am aware of this. i am new to hibernate, not writting code (been doing it for 15 years). i am recieving this error for the following test

Code:
public void testUpdateUser() throws Exception{
      Session s = openSession();
      
      // user1
      UserBean usr = (UserBean) s.load(UserBean.class, new Double(myId));
      assertTrue(usr.getEmail().equals(testEmail1));
      
      usr.setEmail("yomama@ho.com");
      
      s.flush();
      s.connection().commit();
      s.close();
   }


as you can see i am not doing a check on the ids, only for loading. but wouldn't

Code:
if(myId.equals(myId2)){...}


work the same as described in the j2se api?

have i misunderstood something on how the load works? i have doubled checked my schema and bean/test classes and all is in order.

thanks,

jason

p.s. - you have done a wonderful job on hibernate, this is saving me a great deal of time and providing a very robust data layer. just the learning curve.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2004 3:06 pm 
Beginner
Beginner

Joined: Tue Dec 30, 2003 1:51 pm
Posts: 49
Location: Michigan, USA
:-) I have gotten everything to work now!

thank you guys for the help!


---jason


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.