java - How to index a super class property in Objectify when super class is not an @Entity -


tl;dr: possible set @index objectify entity property when property derived non-@entity super class.

long version:

a java project contains abstract model classes used application instead of concrete objects (objectify entities). each such model exists @entity extends model , adds specifics persistence layer (objectify).

a simple example:

public abstract class usermodel {   protected string givenname; }  @entity public class userimpl extends usermodel {   @id   private long id; } 

i chose approach because want use model classes independently persistence layer. therefore model classes cannot contain persistence layer specific annotations or code.

i know in morphia (a mongodb orm) possible annotate @entity class this:

@indexes(@index(value = "supergivenname", fields = {@field("givenname")})) 

is possible achieve similar effect in objectify? not have solution annotations. should possible encapsulate solution in @entity class.

note: post possible solution i'm looking more style / beauty, please don't hesitate answer when have better idea.

i don't think find answer satisfies you. objectify not provide behavior built in.

i assume you're concerned objectify annotations leaking client jar distribute (android or sort of rpc). recommend creating separate model classes api simple reason decouples data model (which change) api (which change on different schedule). it's hard upgrade clients in field. separate classes, can refactor data model using ide without worrying breaking backwards compatibility.

if use http://projectlombok.org, there's 0 boilerplate involved in data transfer objects.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -