wzy

java

常用链接

统计

最新评论

No Dialect mapping for JDBC type: 3

 

public class LabourCostStatImpl {

 

public List getList(){

       Session session = HibernateSessionFactory.getSession();

       String sql="select c.mark, s.towerId, p.daysalary, c.workNum , c.planAttributeId  ,s.powerLevelId from person p,persondaycutplan c,PersonDayCutPlanEquipmentSdgq s  where  c.writerid=p.id and c.id=s.planId ";

       Query query=session.createSQLQuery(sql);

       @SuppressWarnings("unused")

       List list =null;

       if(query!=null){

           list =query.list();

       }

       return list;

    }

   

    }

}

 

 

package test;

 

import java.util.ArrayList;

import java.util.HashSet;

import java.util.Iterator;

import java.util.List;

import java.util.Set;

 

import com.dartfar.sdxl.dao.impl.LabourCostStatImpl;

import com.jxgl.data.dao.exception.DAOException;

 

public class test4 {

 

    /**

     * @param args

     * @throws DAOException

     */

    @SuppressWarnings("unchecked")

    public static void main(String[] args) throws DAOException {

       // TODO Auto-generated method stub

       LabourCostStatImpl labour = new LabourCostStatImpl();

       List list =labour.getList();

       System.out.println(list.size());

           }

    }

 

*********rebuildSessionFactory**********

[20080715 08:51:40,781] [DEBUG] com.jxgl.data.dao.impl.hibernate.PersonDAOHibernateImpl - 得到指定用户名:null 的用户

Exception in thread "main" org.hibernate.MappingException: No Dialect mapping for JDBC type: 3

    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:192)

    at org.hibernate.loader.custom.CustomLoader.getHibernateType(CustomLoader.java:161)

    at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:131)

    at org.hibernate.loader.Loader.getResultSet(Loader.java:1678)

    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:2145)

    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)

    at org.hibernate.loader.Loader.list(Loader.java:2024)

    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)

    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655)

    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)

    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)

    at com.dartfar.sdxl.dao.impl.LabourCostStatImpl.getList(LabourCostStatImpl.java:226)

    at test.test4.main(test4.java:22)

 

if String sql="select c.mark, s.towerId, p.daysalary, c.workNum , c.planAttributeId  ,s.powerLevelId from person p,persondaycutplan c,PersonDayCutPlanEquipmentSdgq s  where  c.writerid=p.id and c.id=s.planId ";则不正确

if String sql="select c.mark from person p,persondaycutplan c,PersonDayCutPlanEquipmentSdgq s  where  c.writerid=p.id and c.id=s.planId "; 则正确

if String sql ="select distinct  towerId id from persondaycutplanEquipmentsdgq where powerlevelId='"+powerlevelId+"'";也正确

 

错误原因:person 表有错误,不知道什么原因,其他表格都可以。

 

      

posted on 2008-07-17 20:55 wzy 阅读(3180) 评论(1)  编辑  收藏

评论

# re: No Dialect mapping for JDBC type: 3 2008-12-18 11:40 huiwb

试试指定类型。实例:query.addScalar("towerId", Hibernate.INTEGER);
  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航: