Giter Site home page Giter Site logo

gaetanopiazzolla / layer3gen Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 16.0 57.66 MB

Easy Auto Generating the SPRING 3 layer architecture ( Controller-Service-Repository) from JPA Entities

Home Page: https://medium.com/p/49f3fbbc7b2d

License: GNU General Public License v3.0

Java 82.76% FreeMarker 15.53% Kotlin 1.72%
freemarker gradle java jpa

layer3gen's People

Stargazers

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

Watchers

 avatar

layer3gen's Issues

Issue generating correct repository key tpye

An issue in generating a repository class using the latest version. I have below table in MySQL.
CREATE TABLE contacts (
CONTACT_ID smallint(6) NOT NULL,
DESCR varchar(100) DEFAULT NULL,
PRIMARY KEY (CONTACT_ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8.

The repository generated as below
public interface ContactModesRepository extends JpaRepository<ContactModes, java.lang.String> {
}

I think the repository should have a key as java.lang.Short, instead it's generated as java.lang.String.

I'm observing similar issue across other tables, For example the entity class have value as java.lang.Long, but repository class key is java.lang.String.

Please help here.

Some enhancements and suggestions

First of all let me praising and appreciate the effort done in this amazing plugin, here are some points that I believe it will make it more awesome :

  • Adding options to generate ControllersDto only or with Controller using entity, as best and common practices, most of developers don't want to expose their entity/db schema in public. (Yaml configuration)
  • Adding options to generate the CrudController Interface or not (Yaml configuration).
  • Adding options to generate the CrudService Interface or not (Yaml configuration).
  • Adding options to specify the dto location package.
  • Adding options to specify the mapper location package.
  • Adding documentation to ensure build project first before running the plugin command. or just update the command to be ./gradlew clean build layer3gen
  • In CrudController all read operation should be in get verb(common convention), but I found @PostMapping("find") and also passing the entity itself, I don't have any clue what is the use for this entity. Pageable rest api, should only take the page and size parameters, also to mention findAll method not need to pass the example, Example<User> example = Example.of(entity); you can just say repository.findAll(pageable); without passing example object.
  • In generated dto found two not needed imports
  • import org.springframework.data.domain.Page; mport org.springframework.data.domain.Pageable;
  • In readOne, in service layer, repository.getOne(primaryKey); getOne is deprecated method and will be removed soon, instead use findById and return Optional object is more common.

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.