• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No Dialect mapping for JDBC type: -1

 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
trans.commit();

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

session.close();
}
catch (Exception exp)
{

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

++++++++++++++++

This is my hibernate.cgf.xml

<session-factory>

<!-- 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"/>

</session-factory>

+++++++++++++++++++++++++++++++++++++++++++

and this is my TestVO.hbm.xml

<hibernate-mapping>

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


<id name="userId" column="1">
<generator class="native"/>
</id>
<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"/>

</class>




</hibernate-mapping>

and i get this exception

>>>>>>>>>>>>>>>>>>>>>>>>>>
org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:231)
at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:559)
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:485)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:501)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1677)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)
at com.aoc.judiciary.framework.daoImpl.TestDaoImpl.insertInfo(TestDaoImpl.java:83)
at com.aoc.judiciary.framework.ejb.BeantestingBean.saveInfo(BeantestingBean.java:64)
at com.aoc.judiciary.framework.ejb.EJSLocalStatelessBeantesting_f63227a0.saveInfo(EJSLocalStatelessBeantesting_f63227a0.java:29)
at com.aoc.judiciary.framework.delegateImpl.LocalTestDelegateImpl.saveInfo(LocalTestDelegateImpl.java:60)
at com.aoc.judiciary.framework.ActionClasses.Action1.test1(Action1.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1282)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:673)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2933)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1912)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:84)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:619)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1462)
>>>>>>>>>>>>>>>>>>>>>>>>>>

any ideas greatly appreciated..
thanks
Jay
[ May 23, 2007: Message edited by: jay roy ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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?

Mark
 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, it works, its a simple select statement
select * from table;

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

thanks
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
works now
thanks all
J
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic