-->
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.  [ 2 posts ] 
Author Message
 Post subject: Provided id of the wrong type
PostPosted: Wed Apr 11, 2007 3:48 am 
Newbie

Joined: Mon Mar 26, 2007 7:50 am
Posts: 18
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


Top
 Profile  
 
 Post subject: SOLVED
PostPosted: Wed Apr 11, 2007 4:32 am 
Newbie

Joined: Mon Mar 26, 2007 7:50 am
Posts: 18
I'm sorry for these posting, but I found the Problem
Of course getHibernateTemplate().load(Class c, Serializable id)
has to be the same Type as the Identifier in the Table.[/b]


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