Hi,
I have a joined-subclass situation as given below. The sub-class as such works as expected and I'm able to fetch the correct type of sub-class. However when I try to access a collection in the sub-class, it gives me the following exception:
Apr 3, 2007 2:29:10 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -1, SQLState: 22018
Apr 3, 2007 2:29:10 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Invalid character string format for type INTEGER.
It looks like a type conversion exception in JDBC but I'm unable to determine where to specify the type to fix this issue.
Hibernate version: 3.2.2
Mapping documents:
User.hbm.xml
Code:
<hibernate-mapping package="com.test.uhg.c4cast.model">
<class name="User" table="USER_INFO" >
<id name="userId" column="USER_ID">
<generator class="assigned"/>
</id>
<property name="password" column="PASSWORD" length="10" not-null="true"/>
<property name="userType" column="USER_TYPE" type="string"/>
<joined-subclass name="Manager" table="MGR_INFO">
<key column="LOGIN_ID"/>
<property name="mgrId" column="MGR_ID" not-null="true" type="long"/>
<property name="firstName" column="FIRST_NAME" not-null="true" length="30" type="string"/>
<property name="lastName" column="LAST_NAME" length="30" type="string"/>
<property name="email" column="EMAIL" length="50" type="string"/>
<property name="phoneNbr" column="CONTACT_NBR" type="string"/>
<property name="type" column="MGR_TYPE" type="integer"/>
<set name="applications" cascade="save-update" inverse="true">
<key column="MGR_ID"/>
<one-to-many class="Application"/>
</set>
<set name="contractors" lazy="true" cascade="save-update" inverse="true">
<key column="MGR_ID"/>
<one-to-many class="Contractor"/>
</set>
</joined-subclass>
</class>
</hibernate-mapping>
Application.hbm.xmlCode:
<class name="Application" table="APPLICATION_INFO">
<id name="applicationId" column="APP_ID" unsaved-value="-1">
<generator class="increment"/>
</id>
<property name="name" column="NAME" not-null="true" length="30"/>
<property name="startDate" column="START_DT" not-null="true"/>
<property name="endDate" column="END_DT"/>
<property name="psftId" column="PSFT_ID"/>
<property name="type" column="PRJ_TYPE" not-null="true"/>
<property name="contractors" column="CNTR_IND"/>
<many-to-one name="manager" column="MGR_ID"
class="Manager" not-null="true"/>
<many-to-one name="rateInfo" class="AppRateInfo"
column="RATE_ID" not-null="true"/>
</class>
Code between sessionFactory.openSession() and session.close():Code:
SessionFactory factory;
try {
//factory = new AnnotationConfiguration().configure("hibernate.cfg.xml").buildSessionFactory();
factory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
} catch (Throwable ex) {
// Log exception!
throw new ExceptionInInitializerError(ex);
}
System.out.println("Factory created");
Session session = factory.openSession();
Transaction tx = session.beginTransaction();
Object o = session.get(User.class,"anandbn");
System.out.println(o.getClass().getName());
Full stack trace of any exception that occurs:Apr 3, 2007 2:29:10 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -1, SQLState: 22018
Apr 3, 2007 2:29:10 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Invalid character string format for type INTEGER.
Name and version of the database you are using:Apache Derby Network Server - 10.2.2.0
The generated SQL (show_sql=true):Code:
select applicatio0_.MGR_ID as MGR8_1_, applicatio0_.APP_ID as APP1_1_, applicatio0_.APP_ID as APP1_0_0_, applicatio0_.NAME as NAME0_0_, applicatio0_.START_DT as START3_0_0_, applicatio0_.END_DT as END4_0_0_, applicatio0_.PSFT_ID as PSFT5_0_0_, applicatio0_.PRJ_TYPE as PRJ6_0_0_, applicatio0_.CNTR_IND as CNTR7_0_0_, applicatio0_.MGR_ID as MGR8_0_0_, applicatio0_.RATE_ID as RATE9_0_0_ from APPLICATION_INFO applicatio0_ where applicatio0_.MGR_ID=?
Debug level Hibernate log excerpt: