Skip to content
Quick and easy use of JPA with a DAO so instant it will shock you.
Branch: master
Clone or download
kg6zvp Update changelog with experimental/new features
Signed-off-by: Sam McCollum <smccollum@mccollum.enterprises>
Latest commit 398f4ea Oct 8, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
prod
tests
.editorconfig refactor utils and fix editorconfig Sep 21, 2018
.gitignore prepare poms for publishing, closes #3 Sep 11, 2018
.gitlab-ci.yml use stable thorntail in tests Oct 9, 2018
CHANGELOG.md Update changelog with experimental/new features Oct 9, 2018
LICENSE README cleanup and add license info Sep 13, 2018
README.md Update Apache license badge, add Maven Central badge Sep 18, 2018
deploy_release.sh use Collections instead of Lists Sep 13, 2018
pom.xml remote root pom Sep 21, 2018

README.md

Sudden DAO

Quick and easy use of JPA with a DAO so instant it will shock you.

License Maven Central pipeline status

A DAO (Data Access Object) is almost always needed in a java project. Extend the eisiges.sudden_dao.GenericPersistenceManager class and that's it.

Use Cases

  1. Query a database for a list of all objects whose values match an object's non-null object member variables
Rock keyRock = new Rock();
keyRock.setColor(Color.BLUE);
List<Rock> blueRocks = rockManager.getMatching(keyRock);
  1. Retrieve an object's primary key
rockManager.getId(myObject);

Getting started

  1. Add sudden-dao to your project

Maven:

		<dependency>
			<groupId>es.eisig</groupId>
			<artifactId>sudden-dao</artifactId>
			<version>1.0.0</version>
		</dependency>

Gradle:

repositories {
	mavenCentral()
}

dependencies {
	implementation 'es.eisig:sudden-dao:1.0.0'
}
  1. Create a class extending eisiges.sudden_dao.GenericPersistenceManager

  2. Create an empty constructor which calls super(Class<T> entityClass)

  3. (optional) add additional methods

@Local // javax.ejb.Local
public class UserBean extends GenericPersistenceManager<MyUser, Long> { // MyUser: entity being managed, Long: type of primary key
	public UserBean(){
		super(MyUser.class);
	}

	public TypedQuery<MyUser> getByBirthdateAsc() {
		return this.find().sortBy(MyUser_.birthdate).ascending().build();
	}
}

The following functions are exposed by GenericPersistenceManager:

boolean containsKey(K)

T persist(T)

K getId(T)

T save(T)

T get(K)

void remove(T)

void saveAll(Collection<T>)

void removeAll(Collection<T>)

List<T> getAll()

boolean isTableEmpty()

List<T> getMatching(T)
You can’t perform that action at this time.