I have an @entity class Resident which is a @subclass of an @entity class User. Resident has a @parent Ref, but User does not. The problem arises when I query and retrieve a Resident meant to be cast as User. This should be fine:
load().type(User.class).filter("email", email).first().now();
But in KeyMetadata.java it throws a IllegalStateException when the entity retrieved has a parent and the class were creating does not. Why throw in this case? Cant it just do the following or am I missing something?
if (parentKey != null) {
/* this exception doesnt seem necessary
if (this.parentMeta == null) throw new IllegalStateException("Loaded Entity has parent but " + clazz.getName() + " has no @Parent");
*/
if (this.parentMeta != null) {
parentMeta.setValue(pojo, (Value) KeyValue.of(parentKey), ctx, containerPath);
}
}
I have an @entity class Resident which is a @subclass of an @entity class User. Resident has a @parent Ref, but User does not. The problem arises when I query and retrieve a Resident meant to be cast as User. This should be fine:
load().type(User.class).filter("email", email).first().now();
But in KeyMetadata.java it throws a IllegalStateException when the entity retrieved has a parent and the class were creating does not. Why throw in this case? Cant it just do the following or am I missing something?