Code Monkey home page Code Monkey logo

dao-builder's Introduction

Dao-builder

Builds JAVA JDBC SQL Database components from POJO

This component will allow you to define a Java POJO object like ABCBO.java and have it auto generate the SQL structure for some basic queries like insert,update,delete and fine. Reason for this component was DAOs are always hard and time consuming to build this just helps automate the process a bit. When using this library it does require some dependencies

dependencies {
implementation 'org.slf4j:slf4j-log4j12:2.0.10'
implementation 'org.springframework:spring-jdbc:5.3.16'
}

For working example please see ExampleBO.java inside the examples.persist directory

Annotations:

@DatabaseField(name = "ID", isPrimaryKey = true) - This should be placed on the primary key field to generate a primary key statement

@DatabaseField(name = "NAME", isSearchField = true, searchFieldSqlName = "SELECT_BY_SURNAME") - This should be placed on your secondary search field When using isSearchField = true, you can specify the searchFieldSqlName select statement name to help build more support for multiple field search

@DatabaseField(name = "SURNAME") - This annotates a field as a regular field and is included in create,update,delete,insert

@DatabaseField(name = "CREATED", isTimestampField = true) - isTimestampField will convert the time from date to long on the row mapper

@DatabaseField(name = "status", isEnumField = true) - isEnumField will convert the Enum to a string insert it and decode it back

To have the interface return a List of objects on a return statement simply specify isSearchFieldMultiple = true

@DatabaseField(name = "NAME", isSearchField = true, isSearchFieldMultiple = true, searchFieldSqlName = "SELECT_BY_NAME") private final String name;

Running this from IntelliJ or Eclipse you need the following setup:
main class: com.sussoftware.daobuilder.DAOBuilder

Example JVM parameters:


-DclassName="com.sussoftware.daobuilder.examples.ExampleBO"
-Ddirectory="src/main/java/com/sussoftware/daobuilder/examples/persist"
-DpackageName="com.sussoftware.daobuilder.examples.persist"
-Djournal=true
Note: -Djournal=true is optional if set, then a new method to create a journal of the table will be added

Gradle

Gradle: implementation 'io.github.susspectsoftware-dev:dao-builder:1.16.0'

dao-builder's People

Contributors

susspectsoftware-dev avatar

Watchers

 avatar

dao-builder's Issues

Support for enum types

When the DAO Object has an enum like Status the code should support a rowMapper that can convert from a string to the enum value.

Better logging for errors

When we have errors, we should throw better statements for logging this:

Exception in thread "main" java.lang.NullPointerException
at com.sussoftware.daobuilder.DAOBuilder.buildDAO(DAOBuilder.java:86)
at com.sussoftware.daobuilder.DAOBuilder.start(DAOBuilder.java:42)
at com.sussoftware.daobuilder.DAOBuilder.main(DAOBuilder.java:73)

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.