Skip to content

TheolZacharopoulos/greenDao-schema-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GreenDao Schema Builder.

Builds a GreenDAO schema from a given domain model using java reflection.

Schema Builder

A SchemaBuilder object can be used to generate a greenDao schema that is based on a domain model class, including relationships, interface implementations and super classes.

How to use it

// The entity class is a model class.
Class<?> entityClass = Document.class;

// Set up the model
SchemaBuilder schemaBuilder = new SchemaBuilder(0.1, "com.example.schema", "./src/main/java");

// Exclude this static field.
schemaBuilder.addFieldToBlackList("ENTITY_NAME");

// Add an entity that is based on a model class.
schemaBuilder.addEntityProperty(
        new PropertyOptions(
            entityClass,                    // the entity Class.
            "code",                         // The primary key field name.
            entityClass,                    // Any super classes.
            "com.example.schemaIEntity")    // Any interfaces to be implemented.
    );

// Add a new relation One To One between Document and Transaction.
schemaBuilder.addEntityRelation(
        new EntityRelation(
                Document.class,
                Transaction.class,
                "transaction",
                EntityRelationType.ONE_TO_ONE));

// Generate the schema.
schemaBuilder.generate();

How To Contribute

Create a java project import from existing sources. Add to your dependencies:

  • DaoGenerator-1.3.0
  • greendao-2.0.0
  • freemarker-2.3.14

About

Builds a GreenDAO schema from a given domain model using java reflection.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages