zoukankan      html  css  js  c++  java
  • hibernate学习手记(1)

    1. java.sql.SQLException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configu 

    出现该问题,是因为时区没有指定,需要在连接字符串上加上 serverTimezone=UTC

    最终的链接语句是 jdbc:mysql:///demo-hibernate?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC

    2. org.hibernate.MappingException: Unknown entity: DBModel.Students 

    出现该问题,有好几个原因,有些是配置文件的引用问题,如果说我们在cfg.xml中点击hbm.xml能跳转到相应的文件,说明引用没问题。

    我出现这个问题是应为hibernate的版本问题,类库用的高版本,代码里面还是用的旧的写法

    我一开始是这么写的

     ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();

    后来看到这篇文章 http://www.imooc.com/wenda/detail/339079 改成了

    ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).configure().build();

    问题就没了

    3.org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [*.hbm.xml]

    这个错误是因为 cfg.xml文件中<mapping  />的配置问题,检查一下是不是有单词拼写错误

    4.org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found : *.hbm.xml : origin(*.hbm.xml)

    这个问题比较恶心,原来我配置原件都是放在src下面的 后来看了这篇文章  http://stackoverflow.com/questions/7127608/org-hibernate-mappingnotfoundexception-resource-hbm-xml-not-found 有所感悟,我看了下编译后的文件(traget文件夹下)确实没有hibernate的配置文件,后来加了一个 resources 文件夹,把配置都放到该文件下,再在build path添加一下就好了

  • 相关阅读:
    VBA 的编写与执行
    C# eBook
    【转】Winfrom datagridview 打印
    jquery循序渐渐1
    C# 数据库备份及还原
    Asp.net调用RAR压缩 解压文件
    SQL Server 2005下的分页SQL
    优秀文档收藏
    动态传入“表名,字段名,字段类型,默认值”四个字符串,根据新的字段名称和类型来创表表结构
    一句话搞定生日提示
  • 原文地址:https://www.cnblogs.com/jpwahaha/p/6834102.html
Copyright © 2011-2022 走看看