Need to put this down in case i forget
beans = {
compass(org.compass.spring.LocalCompassBean){
mappingScan = "persisted"
compassSettings = ["compass.engine.connection":"gae://index",
"compass.executorManager.type":"disabled",
"compass.engine.store.gae.cacheMetaData":"true",
"compass.engine.store.gae.flushRate":"50"]
}
sameThreadParallelIndexExecutor(org.compass.gps.device.support.parallel.SameThreadParallelIndexExecutor){
}
jpaGpsDevice(org.compass.gps.device.jpa.JpaGpsDevice){
name="appengine"
entityManagerFactory = entityManagerFactory
parallelIndexExecutor = sameThreadParallelIndexExecutor
}
compassGps(org.compass.gps.impl.SingleCompassGps){
compass = compass
gpsDevices = [jpaGpsDevice]
}
}
Showing posts with label JPA. Show all posts
Showing posts with label JPA. Show all posts
Thursday, December 23, 2010
Tuesday, August 31, 2010
JPA query syntax
Within a controller:
def query = entityManager.createQuery("select from Account a where a.key=:key order by ${params.sort} ${params.order}")
query.setParameter("key",session.key)
query.setMaxResults( params.max )
query.setFirstResult( params.offset )
def accounts = query.resultList;
EntityManager isn't injected in Services but jpaTemplate is so:
private getEntityManager(){
jpaTemplate.execute({EntityManager entityManager->
return entityManager;
} as JpaCallback);
}
def query = entityManager.createQuery("select from Account a where a.key=:key order by ${params.sort} ${params.order}")
query.setParameter("key",session.key)
query.setMaxResults( params.max )
query.setFirstResult( params.offset )
def accounts = query.resultList;
EntityManager isn't injected in Services but jpaTemplate is so:
private getEntityManager(){
jpaTemplate.execute({EntityManager entityManager->
return entityManager;
} as JpaCallback);
}
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();
}
Subscribe to:
Posts (Atom)