Git Product home page Git Product logo

greatestsql_p1's Introduction

Greatest SQL

Project Description

A java based ORM for simplifying connecting to and from an SQL database without the need for SQL or connection management.

Technologies Used

  • PostgreSQL - version 42.2.12
  • Java - version 8.0
  • Apache commons - version 2.1

Features

List of features ready and TODOs for future development

  • Easy to use and straightforward user API.
  • No need for SQL, HQL, or any databse specific language.
  • Straightforward and simple Annotation based for ease of use.

To-do list:

  • Mapping of join columns inside of entities.
  • Implement of aggregate functions.
  • Allow ORM to build table based on Annotations in Entities.

Getting Started

Currently project must be included as local dependency. to do so:

  git clone https://github.com/210119-java-enterprise/GreatestSQL_p1.git
  cd GreatestSQL_p1
  mvn install

Next, place the following inside your project pom.xml file:

  <dependency>
    <groupId>com.revature</groupId>
    <artifactId>greatestSQL_p1</artifactId>
    <version>1.0-SNAPSHOT</version>
  </dependency>

Finally, inside your project structure you need a application.proprties file. (typically located src/main/resources/)

 url=path/to/database
 admin-usr=username/of/database
 admin-pw=password/of/database  

Usage

Annotating classes

All classes which represent objects in database must be annotated.

  • @Table(name = "table_name)

    • Indicates that this class is associated with table 'table_name'
  • @Column(name = "column_name)

    • Indicates that the Annotated field is a column in the table with the name 'column_name'
  • @Setter(name = "column_name")

    • Indicates that the anotated method is a setter for 'column_name'.
  • @Getter(name = "column_name")

    • Indicates that the anotated method is a getter for 'column_name'.
  • @PrimaryKey(name = "column_name")

    • Indicates that the annotated field is the primary key for the table.
  • @SerialKey(name = "column_name")

    • Indicates that the annotated field is a serial key.

User API

  • public static GSQL getInstance()

    • returns the singleton instance of the class. It is the starting point to calling any of the below methods.
  • public HashMap<Class<?>, HashSet> getCache()
    • returns the cache as a HashMap.
  • public boolean addClass(final Class<?> clazz)

    • Adds a class to the ORM. This is the method to use to declare a Class is an object inside of the database.
  • public boolean UpdateObjectInDB(final Object obj,final String update_columns)

    • Updates the given object in the databse. Update columns is a comma seperated lsit fo all columns in the onject which need to be updated
  • public boolean removeObjectFromDB(final Object obj)

    • Removes the given object from the database.
  • public boolean addObjectToDB(final Object obj)

    • Adds the given object to the database.
  • public Optional<List> getListObjectFromDB(final Class <?> clazz, final String columns, final String conditions)
  • public Optional<List> getListObjectFromDB(final Class <?> clazz, final String columns, final String conditions,final String operators)
  • public Optional<List> getListObjectFromDB(final Class<?> clazz)
    • Gets a list of all objects in the database which match the included search criteria
      • columns - comma seperated list of columns to search by.
      • conditions - coma seperated list the values the columns should match to.
      • operators - comma seperated list of operators to apply to columns (AND/OR) in order that they should be applied.
  • public void beginCommit()

    • begin databse commit.
  • public void Rollback()

    • Rollback to previous commit.
  • public void Rollback(final String name)

    • Rollback to previous commit with given name.
  • public void setSavepoint(final String name)

    • Set a savepoint with the given name.
  • public void ReleaseSavepoint(final String name)

    • Release the savepoint with the given name.
  • public void enableAutoCommit()

    • Enable auto commits on the database.
  • public void setTransaction()

    • Start a transaction block.
  • public void addAllFromDBToCache(final Class<?> clazz)

    • Adds all objects currently in the databse of the given clas type to the cache.
  • License

    This project uses the following license: GNU Public License 3.0.

greatestsql_p1's People

Contributors

return5 avatar

Watchers

 avatar

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.