前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Hibernate 4 升级到 5 后显示未知实体错误

Hibernate 4 升级到 5 后显示未知实体错误

作者头像
HoneyMoose
发布于 2019-10-16 02:59:05
发布于 2019-10-16 02:59:05
59800
代码可运行
举报
文章被收录于专栏:CWIKIUSCWIKIUS
运行总次数:0
代码可运行

提示的错误信息如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
org.hibernate.MappingException: Unknown entity: com.ossez.reoc.common.crm.DoNotCall
  at org.hibernate.metamodel.internal.MetamodelImpl.entityPersister(MetamodelImpl.java:670)
  at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1721)
  at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:118)
  at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
  at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:38)
  at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
  at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:32)
  at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
  at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:713)
  at org.hibernate.internal.SessionImpl.save(SessionImpl.java:705)
  at org.hibernate.internal.SessionImpl.save(SessionImpl.java:700)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:350)
  at com.sun.proxy.$Proxy51.save(Unknown Source)
  at com.ossez.reoc.common.Factory.save(Factory.java:159)
  at com.ossez.reoc.common.crm.factories.DoNotCallFactory.save(DoNotCallFactory.java:27)
  at com.ossez.reoc.common.tests.DoNotCallTest.testCreate(DoNotCallTest.java:23)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at junit.framework.TestCase.runTest(TestCase.java:176)
  at junit.framework.TestCase.runBare(TestCase.java:141)
  at junit.framework.TestResult$1.protect(TestResult.java:122)
  at junit.framework.TestResult.runProtected(TestResult.java:142)
  at junit.framework.TestResult.run(TestResult.java:125)
  at junit.framework.TestCase.run(TestCase.java:129)
  at junit.framework.TestSuite.runTest(TestSuite.java:252)
  at junit.framework.TestSuite.run(TestSuite.java:247)
  at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
  at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
  at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

这个错误很有可能是你的 SessionFactory 在初始化的时候出现了错误。

导致了 Hibernate 不能找到正确的实体配置。

请参考: Hibernate 4 升级到 Hibernate 5 的时候 SessionFactory 不能使用 中的内容。

本文转载自:https://blog.ossez.com/archives/3068

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
GenericJDBCException: could not insert: [com.sns.bean.User]
##原因:当使用uuid当主键的时候 使用Hibernate 并且将其实体映射 <generator class="native" /> 设为自动增长时会报此异常,因为uuid为字符型的无法使用数字型的自动增长。
西门呀在吹雪
2020/11/09
6990
Hibernate 5 测试的时候日志错误
Add org.apache.logging.log4j:log4j-core:2.13.1 到 依赖中。
HoneyMoose
2020/04/08
4520
SpringBoot2版本Caused by: java.sql.SQLSyntaxErrorException: Table 'dinner.hibernate_sequenc
1、SpringBoot2版本Caused by: java.sql.SQLSyntaxErrorException: Table 'dinner.hibernate_sequenc报错。
别先生
2019/07/10
1.5K0
Hibernate 5 在保存数据的时候提示数据库没有选择
09:06:40.277 [http-nio-8080-exec-1] ERROR o.h.id.enhanced.TableStructure - could not read a hi value
HoneyMoose
2020/04/15
1.6K0
Hibernate 5 在保存数据的时候提示数据库没有选择
java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate() or executeLargeUpdate().
java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate() or executeLargeUpdate().
一个会写诗的程序员
2018/08/17
2.2K0
IP不能作为rocketmq 的topic
org.apache.rocketmq.client.exception.MQClientException: The specified topic[182.16.226.45] contains illegal characters, allowing only ^[%|a-zA-Z0-9_-]+$ For more information, please visit the url, http://rocketmq.apache.org/docs/faq/ at org.apache.rock
MickyInvQ
2020/09/27
1K0
org.springframework.data.redis.serializer.SerializationException: Cannot serialize;
前言 本文中提到的解决方案,源码地址在:perfect-ssm,希望可以帮你解决问题。 问题描述 在Spring与Redis整合过程中,出现了如下报错: org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.Serializati
程序员十三
2018/03/15
3.2K0
org.springframework.data.redis.serializer.SerializationException: Cannot serialize;
RedisTemplate执行lua脚本,集群模式下报错解决
在使用spring的RedisTemplate执行lua脚本时,报错EvalSha is not supported in cluster environment,不支持cluster。
stys35
2020/04/12
4K0
一次org.springframework.jdbc.BadSqlGrammarException ### Error querying database Cause: com.mysql.jdbc.
因为在表设计中有一个商品描述字段被设置为desc,但desc是mysql中的关键字,如select id,name,desc,price from product;这条sql语句在查询时的sql语句解析会和期望的不一样,导致出现问题。因为平时在写java代码的时候很自然的会将描述变量设置为desc,在设计表字段时也没有多想,忘记和忽略了desc为mysql中的关键字,酿成此问题。
翎野君
2023/05/12
6900
IKAnalyzer2012FF + Lucene4.9 TokenStream contract violation: reset()/close() call missing
1、Instantiation of TokenStream/TokenFilters which add/get attributes to/ the AttributeSource. 2、The consumer calls reset(). 3、The consumer retrieves attributes the stream and stores local references to all attributes it wants to access. 4、The consumer calls incrementToken() until it returns false consuming the attributes after each call. 5、The consumer calls end() so that any end-of-stream operations can be performed. 6、The consumer calls close() to release any resource when finished using the TokenStream.
全栈程序员站长
2022/09/15
4320
java.lang.NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z
原因是我的 log4j 是最低版本的 1.2.4,解决办法就是升级到 1.2.12+ 的版本。
wsuo
2020/07/31
2.8K0
java.lang.NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z
Java 堆栈信息对象 StackTraceElement,获取当前线程的执行方法
java.langStackTraceElement类保存了Java中线程中的方法栈信息:
青山师
2023/05/05
6800
hibernate.hbm2ddl.auto=update不能自动生成表结构[通俗易懂]
在写上篇文章《spring整合springmvc和hibernate》的时候,曾遇到一个问题
全栈程序员站长
2022/07/18
5700
hibernate.hbm2ddl.auto=update不能自动生成表结构[通俗易懂]
org.springframework.dao.InvalidDataAccessApiUsageException: Cannot locate field code on class .....
报错日志 org.springframework.dao.InvalidDataAccessApiUsageException: Cannot locate field code on class com.ak47.cms.cms.entity.Tree; nested exception is java.lang.IllegalArgumentException: Cannot locate field code on class com.ak47.cms.cms.entity.Tree at o
一个会写诗的程序员
2019/07/02
1.1K0
mybatis连接oracle
原因:oracle jdbc并不能向mysql那样直接配置,原因是Oracle授权问题,Maven不提供oracle JDBC driver,需要手动配置下,这里直接去官网下载,将jar包手动导入idea中
微醺
2019/01/17
1.7K0
spring事务管理
事务是一个不可分割操作序列,也是数据库并发控制的基本单位,其执行的结果必须使数据库从一种一致性状态变到另一种一致性状态。
逍遥壮士
2020/09/18
8090
spring事务管理
聊聊hikari与tomcat jdbc pool的fail fast
本文主要研究在中途数据库挂的情况下,hikari与tomcat jdbc pool的fail fast情况。
code4it
2018/09/17
1.6K0
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: where near line 1, col
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: where near line 1, column 72
qubianzhong
2018/09/19
1.1K0
redis 反序列化deserialize异常问题解决
可以看出是sping对redis查询的返回结果进行deserialize的时候出错了
MickyInvQ
2020/09/27
7.6K0
Lambda表达式在线程安全Map中应用
java.util.concurrent包含两个线程安全的Map,即ConcurrentHashMap类和ConcurrentSkipListMap类。这两个类都是线程安全的和高性能的。但是由于读取修改写入竞争条件,因此使用它们容易出错。Lambda表达式帮助我们优雅地避免了这些竞争条件。
FunTester
2020/06/04
5540
推荐阅读
相关推荐
GenericJDBCException: could not insert: [com.sns.bean.User]
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验