博客
关于我
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
阅读量:792 次
发布时间: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/

你可能感兴趣的文章
nginx访问控制配置
查看>>
nginx负载均衡
查看>>
Nginx负载均衡
查看>>
Nginx负载均衡和F5的区别---系统运维工作笔记001
查看>>
nginx负载均衡和反相代理的配置
查看>>
nginx负载均衡器处理session共享的几种方法(转)
查看>>
nginx负载均衡的5种策略
查看>>
nginx负载均衡的5种策略(转载)
查看>>
nginx负载均衡的五种算法
查看>>
Nginx负载均衡(upstream)
查看>>
nginx转发端口时与导致websocket不生效
查看>>
Nginx运维与实战(二)-Https配置
查看>>
Nginx部署_mysql代理_redis代理_phoenix代理_xxljob代理_websocket代理_Nacos代理_内网穿透代理_多系统转发---记录021_大数据工作笔记0181
查看>>
Nginx配置HTTPS服务
查看>>
Nginx配置Https证书
查看>>
Nginx配置http跳转https
查看>>
Nginx配置ssl实现https
查看>>
nginx配置ssl证书https解决公网ip可以访问但是域名不行的问题
查看>>
Nginx配置TCP代理指南
查看>>
NGINX配置TCP连接双向SSL
查看>>