-->
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: Wrong data type: For input string:
PostPosted: Tue Jun 15, 2004 8:33 am 
Newbie

Joined: Thu Oct 23, 2003 8:19 am
Posts: 14
Location: Tampa, FL USA
I've been away from Hibernate for a while and I feel like I'm back to square one. Any help on this little test would be greatly appreciated. I'm trying to get back up to speed.

Hibernate v2.1.4, HSQLDB 1.7.2RC6b

Cheers,
Steve Maring


THE ERROR:

Code:
    [junit] WARNING: SQL Error: -16, SQLState: 37000
    [junit] Jun 15, 2004 8:13:52 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
    [junit] SEVERE: Wrong data type: For input string: "att" in statement [select user0_.userid as userid1_, user0_.firstname as firstname1_, user0_.lastname as lastname1_, role1_.
roleid as roleid0_, role1_.rolename as rolename0_ from user user0_ left outer join role role1_ on user0_.userid=role1_.roleid where user0_.userid=?]



THE CODE:

Code:
Session session = sessionFactory.openSession();
log.debug( "querying for all users..." );
Query query = session.createQuery( "from com.att.aan.security.dao.User" );
log.debug( "iterating resultset..." );
Iterator iterator = query.iterate();
while ( iterator.hasNext() )
  {
      User user = (User) iterator.next();
      log.info( "found user " + user.getFirstName() + " " + user.getLastName() );
  }
session.close();





THE CONFIG:

Code:
<hibernate-configuration>
      <property name="dialect">net.sf.hibernate.dialect.HSQLDialect</property>
      <property name="show_sql">false</property>
      <property name="use_outer_join">true</property>
         <property name="connection.username">sa</property>
         <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
         <property name="connection.url">jdbc:hsqldb:hsql://localhost:9001/xdb</property>

      <!-- mapping files -->
      <mapping resource="com/att/aan/security/dao/Role.hbm.xml"/>
      <mapping resource="com/att/aan/security/dao/User.hbm.xml"/>
   </session-factory>

</hibernate-configuration>



ROLE.HBM.XML:

Code:
<hibernate-mapping>
    <class
        name="com.att.aan.security.dao.Role"
        table="role"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="roleId"
            column="roleid"
            type="int"
        >
            <generator class="increment">
            </generator>
        </id>

        <property
            name="roleName"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="rolename"
        />

    </class>

</hibernate-mapping>



USER.HBM.XML:

Code:
<hibernate-mapping>
    <class
        name="com.att.aan.security.dao.User"
        table="user"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="userId"
            column="userid"
            type="string"
        >
            <generator class="assigned">
            </generator>
        </id>

        <property
            name="firstName"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="firstname"
        />

        <property
            name="lastName"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="lastname"
        />

        <one-to-one
            name="role"
            class="com.att.aan.security.dao.Role"
            cascade="none"
            outer-join="auto"
            constrained="false"
        />
    </class>

</hibernate-mapping>



DB DDL:

Code:
CREATE TABLE role (
   roleid      integer      primary key,
   rolename   varchar(30)   not null );

CREATE TABLE user (
   userid      varchar(30)   primary key,
   firstname   varchar(30)   not null,
   lastname   varchar(30)   not null,
   password   varchar(30)   not null,
   roleid      integer      ,
   FOREIGN KEY   (roleid)   REFERENCES role(roleid) );
   
INSERT INTO role VALUES ( 101, 'att_admin' );
INSERT INTO role VALUES ( 102, 'cust_admin' );

INSERT INTO user VALUES ( 'att', 'Att', 'User', 'pass', 101 );
INSERT INTO user VALUES ( 'cust', 'Cust', 'User', 'pass', 102 );


Top
 Profile  
 
 Post subject: I think it's something with HSQLDB
PostPosted: Tue Jun 15, 2004 9:49 am 
Newbie

Joined: Thu Oct 23, 2003 8:19 am
Posts: 14
Location: Tampa, FL USA
I just ran the exact same senario with MySQL as the db and it worked!

hmmmm


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.