博客
关于我
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
阅读量:796 次
发布时间:2023-02-16

本文共 1119 字,大约阅读时间需要 3 分钟。

参考文章:

我的环境:

| Grails Version: 3.1.3
| Groovy Version: 2.4.6
| JVM Version: 1.7.0_80
今天在gsp页面查询数据库出现如下错误:
java.lang.IllegalStateException
Message
Request processing failed; nested exception is org.grails.gsp.GroovyPagesException: 
Error processing GroovyPageView: [views/article/create.gsp:33] 
Error executing tag <g:form>: [views/article/create.gsp:27] 
Error executing tag <g:render>: 
Error evaluating expression [xxx.Tag.get(article.tagId)?.id] on line [52]: 
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional one here
Caused by
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional one here
----------------------------------------------------------------------------------------------------------------------------------------------------------------
错误原因:
1、我在gsp页面使用了如下代码来查询数据库:
   <g:set var="selectValue" value="${xxx.Tag.get(article.tagId)?.id}" />
解决方法:
1、在使用领域类查询数据库时加上YourDomainClass.withTransaction{}即可。
如将以上错误代码修改如下即可:

<g:set var="selectValue" value="${xxx.Tag.withTransaction{xxx.Tag.get(article.tagId)?.id}}" />

转载地址:http://hjjfk.baihongyu.com/

你可能感兴趣的文章
neuroph轻量级神经网络框架
查看>>
Neutron系列 : Neutron OVS OpenFlow 流表 和 L2 Population(7)
查看>>
NEW DATE()之参数传递
查看>>
New Relic——手机应用app开发达人的福利立即就到啦!
查看>>
new 一个button 然后dispose,最后这个button是null吗???
查看>>
next项目部署到服务器pm2进程守护
查看>>
nexus上传jar
查看>>
Nexus指南中的更新强调集成和透明度的重要性
查看>>
Nexus指南已经发布
查看>>
NFinal学习笔记 02—NFinalBuild
查看>>
NFS
查看>>
NFS Server及Client配置与挂载详解
查看>>
NFS 服务配置篇
查看>>
NFS共享文件系统搭建
查看>>
nfs复习
查看>>
NFS安装配置
查看>>
NFS服务器配置-服务启动与停止
查看>>
NFS的安装以及windows/linux挂载linux网络文件系统NFS
查看>>
NFS的常用挂载参数
查看>>
NFS网络文件系统
查看>>