-
Notifications
You must be signed in to change notification settings - Fork 0
How into in 5 min

Entities requires public empty constructor and (optional, but good to, to avoid bugs) getters and setters.
Entities could contains other Entities (then u must annotate that as @Table to create a table and @Relation to create relations between them. All fields that must be saved in database must be annotated as @Column, at least one field must be annotated as @Id which means it's primary key. Column could have default values if you initialize field in place. Also Entity could contains arrays and lists, but you must annotate them as @Array, arrays has fixed size, by default it's 10, but you can set size in annotation argument. If you decide to use List's, pay attention that in declaration field of list can only be type of List<> or ArrayList<>.


In configuration class, you declare tables (using @Table annotation) which must be created and other configuration classes. @Drop annotation, means that table which will contains your entity, will be deleted each time you will update database version or restart application.

To get access to basic repository functionality, just create interface annotated as @Repository and extend LightningRepository class.

To make it come to life, invoke SQLightning.run(...) method when your application start.
Than you can call repository builder wherever the app-context is in reach to create required repository and work with database as it is shown in the screenshot below. Pay attention, SQLightning.run(...) must be called only one time, other next calls will be ignored.
That is! You also may read about advanced features here or list of all annotations here.