jDBI Annotation

JPA annotation extension for jDBI

License

License

Categories

Categories

JDBI Data Databases
GroupId

GroupId

com.github.kentyeh
ArtifactId

ArtifactId

jdbi-annotation
Last Version

Last Version

0.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

jDBI Annotation
JPA annotation extension for jDBI
Project URL

Project URL

http://github.com/shakiba/jdbi-annotation
Source Code Management

Source Code Management

http://github.com/shakiba/jdbi-annotation

Download jdbi-annotation

How to add to project

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

Dependencies

compile (3)

Group / Artifact Type Version
javax.persistence : persistence-api jar 1.0
org.jdbi : jdbi jar 2.77
org.slf4j : slf4j-api jar 1.7.21

test (3)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.7.21
com.h2database : h2 jar 1.4.192
org.testng : testng jar 6.8

Project Modules

There are no modules declared in this project.

Deprecation Notice: This project is updated and merged into jDBI 3 by Matthew Hall. This repository is not maintained any more.

JPA annotation extension for jDBI

Extension for jDBI to use JPA annotations for mapping/binding instead of JavaBeans conventions.

Usage

Annotate

Annotate your entity with JPA annotations:

import javax.persistence.Column;
import javax.persistence.Entity;

@Entity
public class Something {
    @Column
    private int id;
    @Column
    private String name;
}

Map

Use AnnoMapper to create ResultSetMapper:

ResultSetMapper<Something> mapper = AnnoMapper.get(Something.class);

Or register AnnoMapperFactory as a ResultSetMapperFactory:

@RegisterMapperFactory(AnnoMapperFactory.class)
public interface SomethingDAO {

    @SqlQuery("select * from Something where id = :id")
    Something get(@Bind("id") long id);

}

Bind

Use @BindAnno instead of @BindBean to bind annotated classes.

public interface SomethingDAO {

    @SqlUpdate("update something set name = :s.name where id = :s.id")
    void update(@BindAnno("s") Something something);

}

Maven

<dependency>
    <groupId>me.shakiba.jdbi</groupId>
    <artifactId>jdbi-annotation</artifactId>
    <version>0.1.1</version>
</dependency>

Versions

Version
0.1.2