Tuesday, September 29, 2009

Datanucleus Level 2 Cache in app engine

Level 2 cache is disabled by default in Datanucleus, 
to enable it you've gotta 
  • download the cache plugin here
  • place it in your applications lib directory
  • edit your persistence.xml and add
    • <property name="datanucleus.cache.level2" value="true">
      <property name="datanucleus.cache.level2.type" value="soft">

      after

      <property name="datanucleus.ConnectionURL" value="appengine"/>
    Additional configuration options are available here.


    App engines memcache implements JCache(javax.cache) interface, but i get a serialization error when attempting to save a object.




    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();
      }