如果出现类似下面的错误:


Exception in thread "main" org.hibernate.MappingException: You may only specify a cache for root <class> mappings
at org.hibernate.cfg.Configuration.getRootClassMapping(Configuration.java:2724)
at org.hibernate.cfg.Configuration.applyCacheConcurrencyStrategy(Configuration.java:2764)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1375)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
at zhongfucheng.aa.App5.main(App5.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Process finished with exit code 1

查看你设置的在配置文件设置的缓存类是否是继承着别的类,也就是说:我开始的时候是配置的是Monkey这个类…而Monkey这个类继承着Animal,因此报错了。。

也就是说:Hibernate在二级缓存中不能配置子类

Exception in thread "main" org.hibernate.MappingException: You may only specify a cache for root的更多相关文章

  1. Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.mao.PersonSet

    转自:https://blog.csdn.net/vipmao/article/details/51334743

  2. 在运行Hibernate Hello World程序的时候,抛如下错误: view plain Exception in thread "main" org.hibernate.exception.LockAcquisitionException 解决方法

    在运行Hibernate Hello World程序的时候,抛如下错误: Exception in thread "main" org.hibernate.exception.Lo ...

  3. Exception in thread "main" org.hibernate.HibernateException: save is not valid without active transaction

    在spring4+hibernate4整合过程中,使用@Transactional注解事务会报"Exception in thread "main" org.hibern ...

  4. Hibernate错误:Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

    报错:Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execu ...

  5. Exception in thread "main" org.hibernate.TransientObjectException: object references an unsaved tran

    今天在使用一对多,多对一保存数据的时候出现了这个错误 Hibernate错误: Exception in thread "main" org.hibernate.Transient ...

  6. ERROR: Field 'PostId' doesn't have a default value Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute statement

    例子: Post p = new Post(); p.setPostId(3); p.setPostName("技术"); 在执行数据保持时提示session.save(p); 的 ...

  7. hibernate添加数据时Exception in thread "main" org.hibernate.PropertyValueException: not-null property references a null or transient value: com.javakc.hibernate.test.entity.TestEntity.testName

    意思是,一个非null属性引用了一个null或瞬态值.就是在对应实体类配置文件hbm.xml中该属性配置了not-null="true",将其去掉即可.

  8. Exception in thread "main" org.springframework.beans.factory.BeanCreationException

    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error ...

  9. Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException 解决方法

    转自:https://blog.csdn.net/gengkunpeng/article/details/6225286?utm_source=blogxgwz4 1. struts2.3.15 hi ...

随机推荐

  1. css3文字与字体样式

    css3使用服务器端字体: <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...

  2. JavaWeb三大组件之一Filter知识总结

    [1] Filter简介    > Filter翻译为中文是过滤器的意思.    > Filter是JavaWeb的三大web组件之一Servlet.Filter.Listener    ...

  3. js 正则,从url中取参数值

    function getQueryString(name) { var reg = new RegExp(name +"=([^&]*)"); var r = window ...

  4. JVM命令工具开发

    1.查看tomcat7_8080的gc状态 $ jps -v | awk '/tomcat7_8080/{print $1}' | xargs jstat -gcutil 2.查看tomcat7_80 ...

  5. Jquery $(this).attr和$(this).val用法示例

    以下是个人心得整理,有兴趣朋友可以参考参考 $(this).attr(key); 获取节点属性名为key的值,相当于getAttribute(key)方法 $(this).attr(key,value ...

  6. DOM+面向对象面试题

    1.dom常见的节点类型---------------------------解彬1510-B 1.nodeType------节点类型,元素节点是1,文本节点是3. 2.firstChild---- ...

  7. 网上搜索到的 比较好的mysql查询语句练习题

    Sutdent表的定义 字段名 字段描述 数据类型 主键 外键 非空 唯一 自增 Id 学号 INT(10) 是 否 是 是 是 Name 姓名 VARCHAR(20) 否 否 是 否 否 Sex 性 ...

  8. 如何编写更好的SQL查询:终极指南-第三部分

    本次我们学习<如何编写更好的SQL查询>系列的最后一篇文章. 时间复杂度和大O符号 通过前两篇文章,我们已经对查询计划有了一定了解.接下来,我们还可以借助计算复杂度理论,来进一步深入地挖掘 ...

  9. Visual Studio2017数据库数据比较

    一.前言 上一篇文章我们介绍了如何使用VS2017对SSMS数据库进行架构比较.这一篇文章我们将继续介绍如何对SSMS数据库的数据进行比较.数据的比较也是很常见的,比如我们要比较当前版本的数据库相对上 ...

  10. element ui datePicker 设置当前日期之前的日期不可选

    pickerOptions0: { disabledDate(time) { return time.getTime() < Date.now() - 8.64e7 } },