So this might be kind of a dumb question but when do you register classes with:
ObjectifyService.register( User.class );
Currently, I\'m doing
Update
Here is the Best Practice Solution:
Use Your Own Service , This guarantees that your entities are registered before you use Objectify, but doesn't necessarily impact application startup for requests which do not access the datastore.
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyService;
public class OfyService {
static {
ObjectifyService.register(User.class);
}
public static Objectify ofy() {
return ObjectifyService.begin();//prior to v.4.0 use .begin() ,
//since v.4.0 use ObjectifyService.ofy();
}
public static ObjectifyFactory factory() {
return ObjectifyService.factory();
}
}
Then use it like this:
public User createUser(User pUser) {
Objectify objectify = OfyService.ofy();
objectify.put(pUser);
return pUser;
}
Original Answer (better use the code above):
you should do it this way in your class, just put a static block like this:
static{
ObjectifyService.register( User.class );
}
p.s , you take a look at the best practice of objectify too
http://code.google.com/p/objectify-appengine/wiki/BestPractices