PGJson

postgres json type support for hibernate

Лицензия

Лицензия

Категории

Категории

JSON Данные
Группа

Группа

com.bazarnazar
Идентификатор

Идентификатор

pgjson
Последняя версия

Последняя версия

1.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

PGJson
postgres json type support for hibernate
Ссылка на сайт

Ссылка на сайт

https://github.com/bazar-nazar/pgjson
Система контроля версий

Система контроля версий

https://github.com/bazar-nazar/pgjson

Скачать pgjson

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.bazarnazar/pgjson/ -->
<dependency>
    <groupId>com.bazarnazar</groupId>
    <artifactId>pgjson</artifactId>
    <version>1.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.bazarnazar/pgjson/
implementation 'com.bazarnazar:pgjson:1.3'
// https://jarcasting.com/artifacts/com.bazarnazar/pgjson/
implementation ("com.bazarnazar:pgjson:1.3")
'com.bazarnazar:pgjson:jar:1.3'
<dependency org="com.bazarnazar" name="pgjson" rev="1.3">
  <artifact name="pgjson" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.bazarnazar', module='pgjson', version='1.3')
)
libraryDependencies += "com.bazarnazar" % "pgjson" % "1.3"
[com.bazarnazar/pgjson "1.3"]

Зависимости

provided (3)

Идентификатор библиотеки Тип Версия
org.hibernate : hibernate-core jar 4.3.0.Final
org.codehaus.jackson : jackson-jaxrs jar 1.9.13
org.postgresql : postgresql jar 9.2-1002-jdbc4

Модули Проекта

Данный проект не имеет модулей.

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.3</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 collection of objects extend PgJsonCollection and override getReturnedTypeReference() like this
    protected TypeReference getReturnedTypeReference() {
        return new TypeReference<Map<String, SomeType>>() {};
    }
  • 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

Версии библиотеки

Версия
1.3
1.2
1.1