Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to generate a java class code from a sqlite database for ORMLite

Tags:

sqlite

ormlite

Given a sqlite database as input, I want to know how can i can generate an ORMLite java class that map with the associated database. Many thanks.

like image 347
androw Avatar asked Oct 11 '22 08:10

androw


2 Answers

I am new to ORMLite and also have the same need.

For SQLite, I read and parse the SQL statement in the field "sql" of table "sqlite_master".

Although it works well with tables, I had to find an other way to deal with views; now I use Excel to load data from views into ADO objects and parse fields' properties to generate Java POJO class definition text, then paste it onto IDE.

It's not perfect, saved me a lot of time though.

like image 31
Wei Lin Avatar answered Nov 15 '22 13:11

Wei Lin


You could try Telosys Tools, an Eclipse plugin for code generation working from an existing database with customizable Velocity templates

See: https://sites.google.com/site/telosystools/

A set of templates is available on GitHub for JPA :

//github.com/telosys-tools-community/jpa-templates-TT206-v2

A Java class for JPA is very near to ORMLite so it's possible to adapt the templates in oder to generate ORMLite java classes

A global tutorial for Spring MVC and JPA :

//sites.google.com/site/telosystutorial/springmvc-jpa-springdatajpa (you can just consider the JPA bundle)

like image 133
rlopez Avatar answered Nov 15 '22 11:11

rlopez