Objectify-Appengine Spring integration
Clone or download
Failed to load latest commit information.
src No commit message Nov 9, 2010
.gitignore added .gitignore Feb 19, 2012
LICENSE.txt No commit message Nov 9, 2010
README.md added readme Feb 19, 2012
pom.xml removed referenced to googlecode Feb 19, 2012


Objectify App Engine Spring

This project contains a Spring FactoryBean to integrate Objectify with the Spring Framework.

First, download the latest objectify-appengine-spring-1.1.jar and include it your application's classpath.

Maven users should add the following dependency instead:


Next, configure the ObjectifyFactoryBean class in your Spring application context. The simplest way to use this class is to provide a basePackage and it will scan for classes annotated with javax.perjavax.persistence.Entity or com.googlecode.objectify.annotation.Entity. Found classes will then be registered in the ObjectifyFactory.

Example configuration:

<bean class="com.googlecode.objectify.spring.ObjectifyFactoryBean" p:basePackage="com.mycompany.domain" />

Multiple basePackages can be provided as well:

<bean class="com.googlecode.objectify.spring.ObjectifyFactoryBean" p:basePackage="com.mycompany.domain;com.othercompany.domain" />

Alternatively it is also possible to explicitly define classes to be registered in the ObjectifyFactory. This approach is useful when you are concerned by App Engine's cold startup times and are not using the context:component-scan option to autodetect classes.

Example configuration:

<bean class="com.googlecode.objectify.spring.ObjectifyFactoryBean">
  <property name="classes">

After the ObjectifyFactoryBean is configured, the ObjectifyFactory can be injected in other classes like:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;

public class CarController {

  @Autowired private ObjectifyFactory objectifyFactory;
  @RequestMapping(method = RequestMethod.GET)
  public String list(Model model) {
    Objectify ofy = objectifyFactory.begin();
    List<Person> persons = ofy.query(Person.class).list();
    model.addAttribute("persons", persons);


Marcel Overdijk

Copyright and License

Copyright 2012 Marcel Overdijk

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.