Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.2
Mapping documents:
Code:
<class name="main.org.jboss.portlet.milestone.spring.security.dto.User"
table="user">
<id column="id" name="id" type="long">
<generator class="increment" />
</id>
<property name="firstname" column="firstname" type="string" />
<property name="lastname" column="lastname" type="string" />
<property name="username" column="username" type="string" />
<property name="email" column="email" type="string" />
<property name="password" column="password" type="string" />
<property name="expired" column="expired" type="boolean" />
<property name="locked" column="locked" type="boolean" />
<property name="enabled" column="enabled" type="boolean" />
<many-to-one name="type"
column="TYPE_ID"
class="main.org.jboss.portlet.milestone.spring.dto.AccessLevel" />
<!-- <property name="" column="" type="" /> -->
</class>
<class name="main.org.jboss.portlet.milestone.spring.dto.AccessLevel"
table="accesslevel">
<id column="id" name="id">
<generator class="increment" />
</id>
<property name="name" column="name" type="string" />
<property name="description" column="description" type="string" />
</class>
in my Controller I call
final Authentication auth = getAuthenticationManager().authenticate(authReq);
authenticate(...) will call:
Code:
public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException, DataAccessException {
if(logger.isDebugEnabled())
logger.debug("UserAuthenticationService.loadUserByUsername");
return (UserDetails)getUserManager().getUserByName(name);
}
and getUserByName(name) looks like these:
Code:
public User getUserByName(String name){
if(logger.isDebugEnabled())
logger.debug("UserManager.getUserByName");
User user = null;
if((user = (User)getHibernateTemplate().load(User.class, name)) != null)
logger.warn("Requested User [ "+name+" ] does not exists, returning null!");
return user;
}
when executing getUserByName(String name)
I get the following error:
Code:
2007-04-11 12:53:25,140 FATAL [main.org.jboss.portlet.milestone.spring.security.controller.AuthenticationController] - Provided id of the wrong type. Expected: class java.lang.Long, got class java.lang.String; nested exception is org.hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class java.lang.Long, got class java.lang.String; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: Provided id of the wrong type. Expected: class java.lang.Long, got class java.lang.String; nested exception is org.hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class java.lang.Long, got class java.lang.String
Any suggestions?
thanks in advance,
Omid