zoukankan      html  css  js  c++  java
  • 关于hibernate的AnnotationConfiguration的问题

      在hibernate4之后就移除了AnnotationConfiguration()方法了,Configuration已经包含了注解的方法,所以你可以直接用:

    Configuration con = new Configuration();
    SessionFactory sf = con.configure().buildSessionFactory();
    Session s = sf.openSession();

    来获得用注解声明映射关系的Session了,加上配置:

      <mapping class="student.Teacher"/>

    就OK了,方便了很多。

    但在配置过程中我还报了一个错误:

     No identifier specified for entity: student.Teacher
    

      这是因为我把主键id的注解加在了setId上,把他加在getId上就解决了。(真是粗心)

  • 相关阅读:
    python函数及模块
    Python分支结构及循环结构
    python基本的知识
    11.21学习总结
    进度日报28
    进度日报27
    进度日报26
    进度日报25
    进度日报24
    11.14学习总结
  • 原文地址:https://www.cnblogs.com/xiaoweihua/p/6970677.html
Copyright © 2011-2022 走看看