Skip to content

Instantly share code, notes, and snippets.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.shin1ogawa</groupId>
<artifactId>gae-jdo-relationships</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>GAE JDO Relationships Sample</name>
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
</properties>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr3-maven-plugin</artifactId>
<version>3.1.3-1</version>
<executions>
<execution>
<configuration>
<goals>
<goal>antlr</goal>
</goals>
@shin1ogawa
shin1ogawa / gist:116190
Created May 22, 2009 15:26
StoreHookListener, StoreHookAdapter
public class StoreHookListener implements StoreLifecycleListener {
public void postStore(InstanceLifecycleEvent event) {
((StoreHookAdapter) event.getPersistentInstance()).postStore();
}
public void preStore(InstanceLifecycleEvent event) {
((StoreHookAdapter) event.getPersistentInstance()).preStore();
}
}
package com.shin1ogawa.entity;
import java.util.Date;
import java.util.logging.Logger;
import javax.jdo.annotations.*;
import com.google.appengine.api.datastore.Key;
import com.shin1ogawa.PersistHookTest.StoreHookAdapter;
package com.shin1ogawa.entity;
import java.util.Date;
import java.util.logging.Logger;
import javax.jdo.annotations.*;
import com.google.appengine.api.datastore.Key;
import com.shin1ogawa.PersistHookTest.StoreHookAdapter;
@Test public void lifecycle() {
pm.addInstanceLifecycleListener(new StoreHookListener(), StoreHookAdapter.class);
SampleEntity entity = new SampleEntity();
Transaction transaction = pm.currentTransaction();
transaction.begin();
try {
pm.makePersistent(entity);
transaction.commit();
} finally {
package com.shin1ogawa;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import com.google.appengine.api.urlfetch.URLFetchServicePb.URLFetchRequest;
import com.google.appengine.api.urlfetch.URLFetchServicePb.URLFetchResponse;
import com.google.appengine.tools.development.ApiProxyLocal;
import com.google.appengine.tools.development.ApiProxyLocalImpl;
package com.shin1ogawa.logic;
import java.io.File;
import org.junit.After;
import org.junit.Before;
import com.google.appengine.api.datastore.dev.LocalDatastoreService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
import com.google.appengine.tools.development.ApiProxyLocal;
package com.shin1ogawa.logic;
import java.io.File;
import org.junit.After;
import org.junit.Before;
import com.google.appengine.api.datastore.dev.LocalDatastoreService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
import com.google.appengine.tools.development.ApiProxyLocal;
package com.shin1ogawa.logic;
import java.io.File;
import org.junit.After;
import org.junit.Before;
import com.google.appengine.api.datastore.dev.LocalDatastoreService;
import com.google.appengine.tools.development.ApiProxyLocal;
import com.google.appengine.tools.development.StreamHandlerFactory;