Sep 29, 2015

Tweaking Column Types in Grails

We had been working on this Grails 2 app for a few weeks and we were finally ready to put it on a test server (instead of running it like run-app locally). More importantly we were ready to point it away from an H2 database and to SQLServer. But then we ran into problems….

SQLServer doesn’t have a boolean type, but instead will use int. And we were using CLOBS and Hibernate was mapping them to text, which is deprecated in SQLServer in favor of nvarchar(max). And a lot of other little things. The CLOB was important to us because we were using that a lot in this app. And there was a bit difference on how H2 handled it as opposed to how SQLServer did.

After googling around the solution came to be to write your own Hibernate Dialiact. That sounded daunting but it actually wasn’t. This is what we came up with:

And then you have to tell Grails about it. In the DataSource.groovy add this to the SQLServer entries:

 dialect = com.foo.MySqlServerDialect

And that should be it.

About the Author

Mike Hostetler profile.

Mike Hostetler

Principal Technologist

Mike has almost 20 years of experience in technology. He started in networking and Unix administration, and grew into technical support and QA testing. But he has always done some development on the side and decided a few years ago to pursue it full-time. His history of working with users gives Mike a unique perspective on writing software.

One thought on “Tweaking Column Types in Grails

  1. Charl says:

    Very helpful, thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Blog Posts
Using Conftest to Validate Configuration Files
Conftest is a utility within the Open Policy Agent ecosystem that helps simplify writing validation tests against configuration files. In a previous blog post, I wrote about using the Open Policy Agent utility directly to […]
SwiftGen with Image & Color Asset Catalogs
You might remember back in 2015 when iOS 9 was introduced, and we were finally given a way to manage all of our assets in one place with Asset Catalogs. A few years later, support […]
Tracking Original URL Through Authentication
If you read my other post about refreshing AWS tokens, then you probably have a use case for keeping track of the original requested resource while the user goes through authentication so you can route […]
Using Spring Beans in a Kafka Streams ExceptionHandler
There are many things to know before diving into Kafka Streams. If you haven’t already, check out these 5 things as a starting point. Bullet 2 mentions designing for exceptions. Ironically, this seems to be […]