With Storm, tables can be mapped to entities with @Table annotation. It works similar to most of the ORM solutions with few exceptions.
Example Mapping:
@Table(name = "DEMO_ENTITY", version = 2) class Entity { @PrimaryKey @Column(name="ID", type = FieldType.INTEGER) private int id; }
Every table must have a @PrimaryKey annotation, or the meta data reading would reject the entity.
Versioning:
One interesting thing to notice here is the version property for the annotation, version helps Storm managing the life-cycle for entity. For example, if you already have a SQLite database and need to add another table, you may update version in @Database annotation and add same version in the @Table annotation.
While the application initializes, Storm would realize the change and execute create table statement on your behalf. You may see @Database details here.
Rest @Column annotation quite self explanatory.
Relations:
Storm can also manage one to one and one to many relations for you. You may choose to map relations using @Relation annotation. An example can be seen here for mapping here on Github.
There are also lot of details on JavaDoc and source that can be accessed here.
Once all tables and entities are mapped with annotations, they can be directly passed to service instances and used for standard functions.
0 Comments