-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with DAO class generator
PostPosted: Tue Jun 12, 2007 12:16 pm 
Newbie

Joined: Tue Jun 12, 2007 11:07 am
Posts: 9
Hi,
I have generate DAO class with Hibernate Tools 3.2 beta 9, bad java compiler (Eclipse 3.2) generate this message error in all "findById" method of all DAO*.java file:

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

Example of method generate:
public ArcFattureAttive findById(int id) {
log.debug("getting ArcFattureAttive instance with id: " + id);
try {
ArcFattureAttive instance = (ArcFattureAttive) sessionFactory
.getCurrentSession().get("geco.data.database.ArcFattureAttive", id);
if (instance == null) {
log.debug("get successful, no instance found");
} else {
log.debug("get successful, instance found");
}
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}

the problem is this call:
.getCurrentSession().get("geco.data.database.ArcFattureAttive", id);

Can you help me?
Regards,
Carlo


Top
 Profile  
 
 Post subject: DAO class generator
PostPosted: Tue Jun 12, 2007 12:44 pm 
Beginner
Beginner

Joined: Thu Jan 13, 2005 10:50 am
Posts: 30
Location: Minneapolis, MN
You should call the methods of the DAO like
Code:
getCurrentSession().get("geco.data.database.ArcFattureAttive", new Integer(id));


instead of
Code:
getCurrentSession().get("geco.data.database.ArcFattureAttive", id);


Please note that I am using the Wrapper class of Integer instead of primitive int.


**Don't forget to rate me if you find this solution useful **
Regards,
Paras


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 2:45 am 
Newbie

Joined: Tue Jun 12, 2007 11:07 am
Posts: 9
I have resolved with appropriating hibernate.reveng.xml:

....
<type-mapping>
<sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Integer"/>
</type-mapping>
....

Thanks,
Carlo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.