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添加一下就好了

  • 相关阅读:
    How Does Batch Normalization Help Optimization?【阅读笔记】
    连接局域网内其他机器虚拟机中的Linux服务器
    阿里云磁盘扩容
    apscheduler模块
    linux挖矿病毒
    jenkins-时间参数
    k8s-学习笔记11-容器探针
    k8s-学习笔记10-watch机制
    xfce4设置屏保/锁屏时间
    高清动图方案
  • 原文地址:https://www.cnblogs.com/jpwahaha/p/6834102.html
Copyright © 2011-2022 走看看