Problem:
==========================
1. Currently Objectify (v4) is completely unaware of namespaces (Datastore
feature that allows multitenancy)
2. Modern apps using multitenancy typically switch namespaces very often.
3. And it looks like this:
final String namespace = NamespaceManager.get();
try {
NamespaceManager.set(null);
return ofy.get().load().....// do work here
} finally {
NamespaceManager.set(namespace);
}
4. Or like this:
public final class OfyUtils {
private OfyUtils() {}
public static void safeWork(String namespace, VoidWork work){
final String original = NamespaceUtils.get();
try {
NamespaceUtils.set(namespace);
work.run();
} finally {
NamespaceUtils.set(original);
}
}
}
OfyUtils.safeWork(namespace, new VoidWork(){
@Override
public void vrun() {
// do work here
}
});
Enhancements:
=========================================================
5. It would be nice to be able to write only
ofy.get().namespace("customer1").load()....
ofy.get().namespace(null/*no ns*/).transact(....
6. Annotation on entities @Namespace(required=true || value="hasrdcodedNS")
Features:
1. Automatic checking that namesapce is set if attrib. required == true
2. Automatic switching of namespace if hardcoded in annotation
Notes:
=================
Its not possible to implement something like:
Clazz cz = OfyUtils.namespace("customer1",
ofy.get().load().type(clazz).id("cz1")).now()
OFY api currently lacks possibility to twiddle with the query builder objects!
Btw: Objectify is very cool:) I love it.
Original issue reported on code.google.com by jan.g...@gmail.com on 12 Apr 2014 at 4:08
Original issue reported on code.google.com by
jan.g...@gmail.com
on 12 Apr 2014 at 4:08