File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes No Dialect mapping for JDBC type: -1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "No Dialect mapping for JDBC type: -1" Watch "No Dialect mapping for JDBC type: -1" New topic

No Dialect mapping for JDBC type: -1

jay roy
Ranch Hand

Joined: Nov 16, 2006
Posts: 145
hi guys

I am doing a hibernate excercise. I am not sure what i am doing wrong. This is what i have in my DAO

Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction trans = session.beginTransaction();
try {
SQLQuery sqlQuery = session.createSQLQuery("SELECT * from dbad.rst_item;");
List getSize = sqlQuery.list();
System.out.println("Size "+getSize);

System.out.println("----------- Close the session------------- ");

catch (Exception exp)

System.out.println("Rollback the session");
// trans.rollback();


This is my hibernate.cgf.xml


<!-- Database connection settings -->
<property name="connection.datasource">jdbc/dwpastoreds</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.DB2390Dialect</property>
<property name="current_session_context_class">thread</property>

<mapping resource="spResourceMapping/TestVO.hbm.xml"/>



and this is my TestVO.hbm.xml


<class name="com.aoc.judiciary.framework.ValueObjects.TestVO" table="RST_ITEM">

<id name="userId" column="1">
<generator class="native"/>
<property name="name" column="2"/>
<property name="city" column="3"/>

<property name="ssn" column="4"/>
<property name="dob" column="5"/>

<property name="extradbmappingfield1" column="6"/>
<property name="extradbmappingfield2" column="8"/>
<property name="extradbmappingfield3" column="9"/>
<property name="extradbmappingfield4" column="10"/>
<property name="extradbmappingfield5" column="13"/>
<property name="extradbmappingfield6" column="14"/>
<property name="extradbmappingfield7" column="15"/>
<property name="extradbmappingfield8" column="16"/>



and i get this exception

org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(
at org.hibernate.dialect.TypeNames.get(
at org.hibernate.dialect.Dialect.getHibernateTypeName(
at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(
at org.hibernate.loader.Loader.getResultSet(
at org.hibernate.loader.Loader.doQuery(
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
at org.hibernate.loader.Loader.doList(
at org.hibernate.loader.Loader.listIgnoreQueryCache(
at org.hibernate.loader.Loader.list(
at org.hibernate.loader.custom.CustomLoader.list(
at org.hibernate.impl.SessionImpl.listCustomQuery(
at org.hibernate.impl.AbstractSessionImpl.list(
at org.hibernate.impl.SQLQueryImpl.list(
at com.aoc.judiciary.framework.daoImpl.TestDaoImpl.insertInfo(
at com.aoc.judiciary.framework.ejb.BeantestingBean.saveInfo(
at com.aoc.judiciary.framework.ejb.EJSLocalStatelessBeantesting_f63227a0.saveInfo(
at com.aoc.judiciary.framework.delegateImpl.LocalTestDelegateImpl.saveInfo(
at com.aoc.judiciary.framework.ActionClasses.Action1.test1(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke( Code))
at sun.reflect.NativeMethodAccessorImpl.invoke( Code))
at sun.reflect.DelegatingMethodAccessorImpl.invoke( Code))
at java.lang.reflect.Method.invoke( Code))
at org.apache.struts.actions.DispatchAction.dispatchMethod(
at org.apache.struts.actions.DispatchAction.execute(
at org.apache.struts.action.RequestProcessor.processActionPerform(
at org.apache.struts.action.RequestProcessor.process(
at org.apache.struts.action.ActionServlet.process(
at org.apache.struts.action.ActionServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(

any ideas greatly appreciated..
[ May 23, 2007: Message edited by: jay roy ]
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

"SELECT * from dbad.rst_item;"

This doesn't look like a valid SQL query. Have you tried copying and pasting it in your db SQL tool to see if it actually runs?


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
jay roy
Ranch Hand

Joined: Nov 16, 2006
Posts: 145
yeah, it works, its a simple select statement
select * from table;

is there any problem with the statement? i am using db2

Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

Which version of DB2 are you using? Anything to do with the dialect that you are using?

Depending on the version of DB2 that you are using, you might want to try out one of thes DB2 dialects mentioned here

[My Blog] [JavaRanch Journal]
jay roy
Ranch Hand

Joined: Nov 16, 2006
Posts: 145
thanks guys . its working now

SQLQuery sqlQuery = session.createSQLQuery("SELECT * from dbad.rst_item;");
List getSize = sqlQuery.list();
System.out.println("Size "+getSize);

tha above statements print "Size 40" in console. however

when i say something like

for (int i = 1; i < getSize .size(); i++) {
TestVO resultSet = (TestVO) getSize .get(i);
System.out.println("userID:" + resultSet.getUserId());


its not working, thats weird. the length is perfectly fine , but when i try to print the values , the code breaks, it says

>>>Could not invoke the service() method on servlet HibernateTestServlet. Exception thrown : java.lang.ClassCastException: java.lang.Object

any ideas?
[ May 24, 2007: Message edited by: jay roy ]
jay roy
Ranch Hand

Joined: Nov 16, 2006
Posts: 145
works now
thanks all
I agree. Here's the link:
subject: No Dialect mapping for JDBC type: -1
jQuery in Action, 3rd edition