Giter Site home page Giter Site logo

pgjson's Introduction

PGJson

Hibernate extension for PostgreSQL json type support

This projects provide some classes to simplify work with Postgres json data type in hibernate. It includes extended postgres dialect and objects for type def support. This small library allows to store in json field both HashMap(with any nesting level) and custom objects. Also it supports scheme validation and update

Requirements

Library expects that in your project you have following dependencies

  • hibernate core(4.3 or higher)
  • jackson (1.9.13) want to add opportunity to support custom converter
  • PostgreSQL driver(9.2 or higher)

How to use

  • include library into your project
        <dependency>
            <groupId>com.bazarnazar</groupId>
            <artifactId>pgjson</artifactId>
            <version>1.1</version>
        </dependency>
  • set com.bazarnazar.pgjson.JsonPostgreSQLDialect as dialect for hibernate
  • if you want to store custom object
    • create object that extends com.bazarnazar.pgjson.PGJsonObject
    • add this object as type in @Type to your @Entity and your annotate field or getter for this type where object is stored
  • if you want to store HashMap
    • simply add com.bazarnazar.pgjson.JsonMapType as type in @Type to your @Entity and your annotate field or getter for this type where Hash map is stored

WARNING!!!

  • If you have native queries in your project, be sure that you adding entity for this query
  • Be careful while editing or passing object for json field. Since it's not immutable changing data directly in this object, can change data in database. It's strongly recommended to create copies

pgjson's People

Contributors

bazar-nazar avatar

Stargazers

 avatar

Watchers

 avatar  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.