jevgeniv / petit

Persistence layer extension

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Petit

Build Status

Petit is a light-weight object-relational mapping framework with a goal to help developers write maintainable database queries. Unlike Hibernate, which aims to be a framework for mapping the object-oriented domain model to traditional relational database, Petit focuses on single model-table mapping, persistence and queries. Petit builds upon Spring Framework's JDBC abstraction framework relieving the developer from writing SQL in Java code, direct resultset handling and object conversion. For persistence Petit uses Plain Old Java Objects (POJOs) that are enhanced with standard JPA annotations.

Dependencies

Petit depends on:

  • Java 7+
  • Spring framework 4.2.5+

Installation

Simply add Petit as a dependency to your project and configure your BaseDAO or similar base class for database to use Petit.

Quick Start Guide

To start using Petit You need to define a base class for your DAO classes. This base class is responsible for initializing and exposing Petit framework functionality.

Simple way to demonstrate is with a small example.

public abstract class PetitBaseDAO implements StatementConfiguration {

   @Resource
   private JdbcTemplate jdbcTemplate;
   
   @Autowired
   private ObjectFactory<StatementBuilder> statementBuilderFactory;
   
   @Resource(name = "beanPropertyConverter")
   private BeanPropertyConverter beanPropertyConverter;

   protected SqlSupport sqlS;
   protected StatementSupport statS;
   
   public PetitBaseDAO() {
      this.sqlS = new SqlSupport(this);
      this.statS = new StatementSupport(this);
   }

   @Override
   public SqlDialect getSqlDialect() {
      return null;
   }

...
}

As shown You need to implement StatementConfiguration (or if You dont need Statement support only SqlConfiguration) interface and supply Spring JdbcTemplate to Petit.

Petit Framework gives You two main support functionalities:

  • SqlSuppport, which gives you various helper methods for constructing SQL statements
  • StatementSupport, which aims to automate SQL generation (see Reference manual in documentation folder for more information)

Petit currently supports two databases: Oracle and Postgresql. Use the corresponding dialect.

About

Persistence layer extension

License:Other


Languages

Language:Java 100.0%