【问题标题】:Grails Hibernate Session Read OnlyGrails Hibernate Session 只读
【发布时间】:2010-11-24 08:03:11
【问题描述】:

我有两个 grails 服务器:

  • 服务器 - 具有对数据库的读/写访问权限
  • Web - 对数据库具有只读访问权限,每次写入都会向服务器发送一个请求

问题:我如何使 Web 的域对象在应用程序的整个运行过程中只在一个位置(配置文件)读取,而不是编写缓存:'read-only' for each domain class' 映射。

【问题讨论】:

    标签: hibernate session grails grails-orm


    【解决方案1】:

    转述自http://www.nabble.com/database-read-only-td20360158.html

    如果您在 DataSource.groovy 中有 pooled=true,则会创建一个 org.apache.commons.dbcp.BasicDataSource。您可以在 BootStrap.groovy 中设置 defaultReadOnly 属性:

    class BootStrap { 
    
          def dataSource 
    
          def init = { servletContext -> 
             dataSource.defaultReadOnly = true 
          } 
    
          def destroy = {} 
    } 
    

    【讨论】:

      【解决方案2】:

      使用 grails 1.3.7

      使用 [dataSourceUnproxied] 而不是 [数据源]

      【讨论】:

        猜你喜欢
        • 2011-04-03
        • 1970-01-01
        • 1970-01-01
        • 2011-07-21
        • 2011-04-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-07
        相关资源
        最近更新 更多