-->
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.  [ 4 posts ] 
Author Message
 Post subject: Getting errors in generated DAO code
PostPosted: Wed Sep 27, 2006 7:25 pm 
Newbie

Joined: Wed Sep 27, 2006 5:42 pm
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: Hibernate Tools 3.2 Beta 7

Name and version of the database you are using: HSQLDB 1.8.1

I'am using eclipse 3.2 with hibernate tools 3.2 beta 7 to generate domain code and DAO code. The domain classes are flawless. However, the generated DAO classes (*Home.java) produce errors saying,

Code:
The method get(String, Serializable) in the type Session is not applicable for the arguments (String, int)".

Sample code is below.

Code:
ProductHome.java

Product instance = (Product) sessionFactory.getCurrentSession().get("org.hibernate.test.Product", id);


Code:
InvoiceHome.java

Invoice instance = (Invoice) sessionFactory.getCurrentSession().get("org.hibernate.test.Invoice", id);


I don't know why I'm getting this since the code is auto-generated.

Please advice. Thanks


Last edited by d70 on Wed Sep 27, 2006 8:19 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 7:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The id is expected to be a java object and not a native type.
I could not say if its an error in the generator or a factor of your configuration. You can fix it by creating an Integer for the id.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 8:58 pm 
Newbie

Joined: Wed Sep 27, 2006 5:42 pm
Posts: 2
Thanks david. I did some more digging and found that those ID columns were recognized as int type by Hibernate whereas JDBC recognized them as Integer type.

So what I did was I added type-mapping in the reveng.xml file. (see below)

Code:
<type-mapping>
   <sql-type jdbc-type="INTEGER" hibernate-type="Integer"
      not-null="true">
   </sql-type>
   <sql-type jdbc-type="INTEGER" hibernate-type="Integer"
      not-null="true">
   </sql-type>
   <sql-type jdbc-type="INTEGER" hibernate-type="Integer"
      not-null="true">
   </sql-type>
</type-mapping>


Now all the errors are gone but I don't know if the code works. Back to the initial problem, is there a way to configure Hibernate to recognize int the database as Integer by default? or a way to fix it right?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 29, 2006 12:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Alternatively, you could provide your own reverse engineering strategy http://www.hibernate.org/hib_docs/tools/reference/en/html/reverseengineering.html#d0e1477


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.