hibernate:XXX is not mapped问题
来源:互联网 发布:java 工作流设计器 编辑:程序博客网 时间:2024/05/20 21:43
hibernate 版本不同,创建SessionFactory方法不同
hibernate5 创建方法为:
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().configure().build();Metadata metadata = new MetadataSources(standardRegistry).getMetadataBuilder().applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE).build();sessionFactory = metadata.getSessionFactoryBuilder().build();Hibernate5不再显式的使用Configuration类代表配置信息,而是新增了一个Metadata类来处理,SessionFactory的创建从Metadata实例中获得一个创建者,然后调用改创建者的build()方法获得SessionFactory。这是典型的创建者模式。
若依旧在Hibernate5中使用Hibernate4创建SessionFactory的方式,代码编译不会报错,但在运行时会抛出一个QuerySyntaxException异常:XXX is not mapped。
这个异常信息似乎告诉我们是因为User类没有映射到数据库的表中,然而我认真检查了所有配置信息,并没有发现配错的情况。于是我把Maven依赖的Hibernate5降级到Hibernate4目前最后一个版本4.3.11,QuerySyntaxException异常没有出现,User类也正常映射到了数据库表中。我一开始还以为是Hibernate5有bug,查看文档之后才发现原来是SessionFactory的创建方式改了。
0 0
- hibernate:XXX is not mapped问题
- hibernate XXX is not mapped
- hibernate:XXX is not mapped问题的解决
- Hibernate 中出现 xxx表 is not mapped xxx的问题
- 关于hibernate的is not mapped问题
- Hibernate XX is not Mapped问题笔记
- hibernate 出现 is not mapped 问题
- hibernate xxx is not mapped 错误原因及解决方法
- hibernate错误 xx is not mapped [from xxx]
- Hibernate Is Not Mapped
- (Hibernate) is not mapped
- Hibernate - is not mapped
- is not mapped 问题
- org.hibernate.hql.ast.QuerySyntaxException: XXX is not mapped [from XXX]
- org.hibernate.hql.ast.QuerySyntaxException: xxx is not mapped [from xxx]
- org.hibernate.hql.ast.QuerySyntaxException: xxx is not mapped [from xxx]
- org.hibernate.hql.internal.ast.QuerySyntaxException: XXX is not mapped [from XXX]
- Hibernate Class Is Not Mapped
- pico-ctf-2013 overflow-2
- 为wordpress安装主题时如何跳过对ftp服务器的验证
- Find Peak Element
- 0426-CSS三大特性之继承性
- MD5加密算法简单实现
- hibernate:XXX is not mapped问题
- PAT 乙等 1018 C语言
- Learning to Compare Image Patches via Convolutional Neural Networks
- 针对自定义标题栏拖动效果问题解决
- Phpstorm激活
- java学习笔记--文件传输io流
- 用 TensorFlow 做个聊天机器人
- Android通过Http连接MySQL 实现登陆/注册(数据库+服务器+客户端)
- 线程通信