Showing posts with label Groovy Grails GORM Problem FileName Long workaround. Show all posts
Showing posts with label Groovy Grails GORM Problem FileName Long workaround. Show all posts

14 October 2013

Groovy / Grails / GORM - File Name Too Long

Yet another "File Name Too Long" workaround :-(

Normal day - was just gonna add one more check to my nice .where{} closure. But when I did, everything blew up in my face - and I'm sitting here with no eyebrows.

The file will no longer compiles!

#grails test-app
/home/finn/src/stratos/stratos/target/classes/no/nsb/stratos/MyService$_updateAllWithChanges_closure5_closure7_closure8_closure9_closure10_closure12_closure14_closure16.class (File name too long)

When I commented back in the validTo everything went melt-down.

List gsmList = DistributionText.where {
  status.enabled==true &&
  status.ok==false &&
  status.validFrom <= new Date() && 

//status.validTo >= new Date() &&
  status.station != null &&
  channelCode=="FOO" &&
  language == "eng"
}.list()


I can't figure out why this happens! The filename isn't over the Linux file length limit. 


I've seen this before when JSON marshalling really deep objects. (the workaroud then, was to create a map from intended object, and serialize the map instead)

So, what to do when you really don't understand the error in front of you? Escape! So I that's what I did - I rewrote to rewrote to Hibernate Criterion.

List<DistributionText> gsmList = DistributionText.createCriteria().list {
status {
  eq("enabled", true)
  eq("ok", false)
  le("validFrom", new Date())
  ge("validTo", new Date())
  isNotNull("station") 
}
eq("channelCode", "FOO")
eq("language", "eng")



I kinda like better the Groovy DSL/where to this Hibernate syntax, so if you find out how to get around the File Name Too Long, please leave a comment.