Saturday, September 26, 2009

Beginning Grails on Google AppEngine

Just a quick writeup on Grails+Gorm-JPA+GAE

What you will need:
At the time of this writeup i'm using
  • Grails 1.1.1
  • GAE 1.2.5
  • appengine plugin 0.8.5
  • gorm-jpa plugin 0.5
Things to note:
  • App engine uses Datanucleus to enhance Domain classes, on Windows there is a character limit on the command line see here one way i found around this problem is to end Domain classes with XXXDomain. e.g. UserDomain.groovy and update %APPENGINE_HOME%/config/user/ant-macros.xml
    from
    ‹fileset dir="@{war}/WEB-INF/classes" includes="**/*.class"›

    to
    ‹fileset dir="@{war}/WEB-INF/classes" includes="**/*Domain.class"›

  • To use google's datatypes in Domains, you have to add the annotation
    @Enumerated
    e.g.
    @Enumerated
    Text longText;
  • Also when bootstrapping do NOT populate the FIRST google datatype in a Domain class,
    this causes the datatype NOT to be mapped.
  • To simplify saving Text datatypes, you can override the default getters and setters on the Domain class like so:
    void setLongText(String text){
    longText = new Text(text);
    }

    String getLongText(){
    return longText?.getValue();
    }

No comments:

Post a Comment