Win a copy of Spring Boot in Practice this week in the Spring forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

hibernate- Dialect mapping for JDBC

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
>>>>>>>>>>>>>>>>>>>>>>>>>>
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
You already posted this question here. Please don't post the same question in multiple forums.
    Bookmark Topic Watch Topic
  • New Topic