hibernate no key for value
来源:互联网 发布:shop 源码下载 编辑:程序博客网 时间:2024/06/07 20:26
最近用 ssh 框架 写的 java 代码。
中有一个保存方法,需要先去不同的表中得到数据 去对比之后 ,正确 再保存。
在一个 service 方法中。spring事务配置中 是 一个 service 一个事务。
调用了 截个 dao。然后取数据,后面验证通过之后 保存。
一直报错: no key for value 。。。
找了很多资料,分析自己的代码好久 ,最好 得到一个结论,网上也有,但是当时没有看懂,自己代码里面 存在 hibernate 的 session 去取数据,保存也是用 的 hibernate的,但是有一个dao取数据 用的 jdbc 方法:
『一个取数据很方便的 方法:但是现在知道这种写法不是 hibernate,而是jdbc支持的。
Session session = this.getHibernateTemplate().getSessionFactory().openSession();
Query query = session.createSQLQuery(sql).setResultTransformer(Transformers.aliasToBean(ExportPointDto.class));
@SuppressWarnings("unchecked")
List<ExportPointDto> list = query.list();
session.close();
if (!list.isEmpty()) {
return list;
}
return null;
将一个sql查到的语句用java对象封装,注意的是 对象里面的字段和 sql 中的 字段名(别名)一致
』
,然后 引起了冲突,(用hibernate的时候一会用datasource的事物(transaction)一会用hibernate的事务 [网上百度的 ])。
所以在 一个 service (一个事务中) 只用一种,那样才能让jvm 识别吧。- hibernate no key for value
- No value for key [org.hibernate.impl.SessionFactoryImpl
- No value for key [org.hibernate.impl.SessionFactoryImpl 异常解决
- No value for key [org.hibernate.impl.SessionFactoryImpl@1b912ed] bound to thread
- java.lang.IllegalStateException: No value for key [org.hibernate.impl.SessionFactoryImpl@af9ce7] bou
- 解决The current branch is not configured for pull No value for key branch.master.
- 解决The current branch is not configured for pull No value for key branch.master.m
- Pull error. No value for key branch.master.merge found in configuration
- egt、GetHub更新本地No value for key branch.master.merge found in configuration
- 已解决:The current branch is not configured for pull No value for key ...(for eclipse)
- for循环: 遍历字典, 分别打印key, value, key:value
- 解决The current branch is not configured for pull No value for key branch.master.merge found in config
- The current branch is not configured for pull No value for key branch.master.merge found in configur
- 解决The current branch is not configured for pull No value for key branch.master.merge found in confi
- egit 出现问题 The current branch is not configured for pull No value for key branch.master.merge found i
- eclipse git 报错:the current branch is not configured for pull No value for key branch.xxx.merge found
- The current branch is not configured for pull No value for key branch.master.merge found in configur
- 解决The current branch is not configured for pull No value for key branch.master.merge found in config
- Android学习笔记(实现跑马灯效果的两种方式 )
- 安卓应用版本升级时sqlit数据库升级
- Visual Studio Ultimate 2012 激活密钥
- release程序加载调用ffmpeg动态库崩溃
- C#生成验证码
- hibernate no key for value
- php session
- Codeforces 444C DZY Love Colors Solution
- Android使用VideoView播放网络视频,获取网络视频缩略图
- android AsyncTask的使用介绍
- Linux之进程创建
- cmake 学习小结
- node批量读取文件时异步变同步的方法分享
- HBase table Put 插入数据