views:

525

answers:

1

Hi. I have two grails servers:

  • Server - has read/write access to the database
  • Web - has read-only access to the database, and for every write it sends a request to the server

The problem: How do I make the Web's domain objects read only in one place (config file) for the entire run of the application, instead of writing caching: 'read-only' for each domain class' mapping.

+1  A: 

Para-phrased from http://www.nabble.com/database-read-only-td20360158.html

If you have pooled=true in DataSource.groovy this creates a org.apache.commons.dbcp.BasicDataSource. You can set the defaultReadOnly property in the BootStrap.groovy:

class BootStrap { 

      def dataSource 

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

      def destroy = {} 
}
John Wagenleitner

related questions