org.panteleyev:persistence

Annotation wrapper for SQLite and MySQL database.

Лицензия

Лицензия

Категории

Категории

Ant Компиляция и сборка
Группа

Группа

org.panteleyev
Идентификатор

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

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

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

19.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

org.panteleyev:persistence
Annotation wrapper for SQLite and MySQL database.
Система контроля версий

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

https://github.com/petr-panteleyev/persistence/tree/master

Скачать persistence

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

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

Зависимости

test (5)

Идентификатор библиотеки Тип Версия
org.testng : testng jar 6.14.3
org.xerial : sqlite-jdbc jar 3.15.1
mysql : mysql-connector-java jar 8.0.15
org.mockito : mockito-core jar 2.24.5
com.google.code.gson : gson jar 2.8.5

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

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

Persistence API

Annotation based wrapper for SQLite and MySQL.

The library is intended for desktop applications that perform insert/update/delete operations only.

BSD-2 license Maven Central Javadocs

Artifact

<dependency>
    <groupId>org.panteleyev</groupId>
    <artifactId>persistence</artifactId>
    <version>19.2.0</version>
</dependency>

Limitations

  • Each new version may introduce incompatible changes
  • No queries, either mapped or raw
  • Basic support for constraints
  • No support for schema migration in case of changes

Data Types

Java SQLite MySQL
String VARCHAR VARCHAR
String with Column.isJson() = true BLOB JSON
BigDecimal VARCHAR ( Column.precision() + 1 ) DECIMAL ( Column.precision(), Column.scale() )
Date INTEGER BIGINT
LocalDate INTEGER BIGINT
byte[] BLOB VARBINARY ( Column.length() )
UUID VARCHAR(36) BINARY(16) or VARCHAR(36)

java.util.Date are stored as long using Date.getTime() java.time.LocalDate is stored as long using LocalDate.toEpochDay()

The following types can be used as primary keys:

  • Integer, int
  • Long, long
  • String
  • UUID

Database independent auto-increment is supported for integer and long keys.

Usage Examples

Immutable Object

@Table("book")
public class Book implements Record {
    @PrimaryKey
    @Column(Field.ID)
    private final int id;
    
    @Column("title")
    private final String title;

    @RecordBuilder
    public Book(@Column(Column.ID) int id, 
                @Column("title") String title) 
    {
        this.id = id;
        this.title = title;
    }

    public int getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }
}

Foreign Keys

@Table("parent_table")
public class ParentTable implements Record {
    @Column(value = "data", unique = true)
    private String data;

    public String getData() {
        return data;
    }
}

@Table("child_table")
public class ChildTable implements Record {
    @Column("parent_data")
    @ForeignKey(table = ParentTable.class, column = "data",
        onDelete = ReferenceOption.RESTRICT, onUpdate = ReferenceOption.CASCADE)
    private final String parentData;

    public String getParentData() {
        return parentData;
    }
}

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

Версия
19.2.0
19.1.0
18.1.1
18.1.0
3.2.1
3.2.0
3.1.0
3.0.0
2.2.1
2.2.0