Giter Site home page Giter Site logo

marcuspocus / jpagen Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 4.0 117 KB

JPAGEN is a module for the Play! Framework that aims at generating JPA Entities and Composite keys from metadata or a file containing a list of tables.

Home Page: http://www.playframework.org/modules/jpagen

Java 88.61% Python 11.39%

jpagen's Introduction

JPAGEN module

This module allows you to import a database tables to POJO instances.

Enable the JPAGEN module for the application

In the conf/application.conf file, enable the JPAGEN module by adding this line:

# The jpagen module
module.jpagen=${play.path}/modules/jpagen-[version]

or in the conf/dependencies.yaml file:
require:
play → jpagen [version]

Creating the conf/table_list.conf file from the database

play jpagen:create-list myapplication

Creating your domain model from the database

play jpagen:generate myapplication

This command will create the classes in the models package based on the database tables. This is useful is you have an existing database and you want to re-use this database.

List of properties you can override in conf/application.conf

  • db.driver (required)
  • db.url (required)
  • db.user (required)
  • db.pass (required)
  • db.default.schema (optional, default="")
  • jpagen.package.name (default=models)
  • jpagen.template.entity (default=jpagen/entity.tmpl)
  • jpagen.template.idClass (default=jpagen/idClass.tmpl)
  • jpagen.template.list (default=jpagen/list.tmpl)
  • jpagen.mode (required, possible values=MYSQL,ORACLE)
  • jpagen.excludes (optional, regular expression)
  • jpagen.includes (optional, regular expression)

Be sure to configure correctly your database access using your conf/application.conf file (db.user, db.pass, db.driver, db.url, etc…).

Made by @flexitpro (Visit flexitpro.com)

jpagen's People

Contributors

marcuspocus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jpagen's Issues

db.default.schema (optional, default="")

Hello,

I'm trying to use jpagen for one of my small projects but every time I got the same error:

11:32:31,063 INFO ~ MLog clients using log4j logging.
11:32:31,339 INFO ~ templateFile: list.tmpl
11:32:32,710 ERROR ~ null
java.lang.NullPointerException
at play.modules.jpagen.ListGenerator.main(ListGenerator.java:64)

I read the documentation again and again and seems everything was right, all the required properties are there. So I went to debugging to find out. While debugging I realize that the error was because I haven't set a value for the "db.default.schema" property. When I did everything worked just fine. I think you can solve this issue by two ways; updating the documentation and define "db.default.schema" as required or change the code to really accept it as empty property:

I also did the second one, my one cent contribution is below:
I commented the following lines:

>46:  //if (temp.length() > 1) {
47:     schemas = temp.split(",");
>48:  //}

and also including this:

>72:  if(schema.length()>0)
73:        table = schema + "." + rs.getString("TABLE_NAME").trim();
>74:  else
>75:     table = rs.getString("TABLE_NAME").trim();

With this little and dirt mod the "db.default.schema" property can be empty.

Another changing I made was in the Generator. My tables are all capitalized like BASE_SOFTWARE then the generated class was capitalized too, like BASESOFTWARE. So I changed the following line:

182:    column.columnPropertyName = JavaExtensions.camelCase(column.columnName.replaceAll("_", " "));

by this one:

182:    column.columnPropertyName = JavaExtensions.camelCase(column.columnName.toLowerCase().replaceAll("_", " "));

And then the generated class was named BaseSoftware.

Forgive me if I was not clear, English is not my primary language.

Thank you for this module.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.