Home > RepositoryJPA

RepositoryJPA

RepositoryJPA is a project mainly written in Java, it's free.

Intends to be a generic repository for JPA instances


TODO

Validar as entidades - Ok Inclusao de objetos - Ok Alteracao - Ok Exclusao logica - Ok Listagem sem parametros - Ok Consulta parametrizada - Ok Validar a estrutura - Ok Buscar apenas itens ativos - Ok Colocar enums para o inicio da consulta - Ok

Lancar excecao no Keeper - Ok

Documentar o Utils. Estudar o Arquilian

Consulta by Google. Reescrever Readme. Documentar o codigo. Traduzir mensagens de erro.

Seeker s = new Seeker(); List l = s.seekAll(X.class) -- OK

List l = s.seekByExample(X.class, object); -- OK X x = s.seekOne(X.class) -- OK Long qtde = s.count(X.class) -- OK

Proposicoes: AND(new Equals(...), new Between(...)) -- OK OR(new Equals(...), new Between(...)) -- OK NOT(...) -- OK ORDERBY -- OK

Modificar o Like -- OK

Lancar excecao JPQL - Ok

Proposicao composta nao tem order by. -- OK

Testar: Seeker s = new Seeker(); s.searchAll(Carro.class); s.searchAll(Moto.class); s.searchAll(Bicicleta.class);


RepositoryJPA

This project intends to be a generic repository for JPA instances.

It isolates the developer from knowing the databases and transactions and criterias.

Usage

Keeper k = new Keeper(); k.persist(instance); k.remove(instance); k.remove(instance, RemoveEnum.LOGICAL) k.remove(instance, RemoveEnum.PHYSICAL)

Seeker s = new Seeker(); s.giveme(ALL/SINGLE, X.class); s.whose(new Equals("field", value)); s.go();

Requirements

The entities have to fulfill some requirements before persist.

  1. It must have an @Entity.
  2. It must implements Serializable.
  3. It must have a Long id field, annotated with @Id.
  4. It must have an Integer version field, annotated with @Version.
  5. It must have a Boolean active field (for logical removal).
  6. It must have a public constructor without arguments (or none, if there aren't any other constructors).
  7. It must have an Equals and a HashCode methods.

There is an example:

@Entity public class BasicEntity implements Serializable {

@Id
private Long id;

@Version
private Integer version;

private Boolean active;

public Entidade(){
}

@Override
public boolean equals(Object obj) {
    return super.equals(obj);
}

@Override
public int hashCode() {
    return super.hashCode();
}

}

Development Environment


Eclipse IvyDE JPA (Hibernate) CDI (Weld) RepositoryJPA

JUnit Mockito HSQLDB

It uses ProjectJPA to execute tests

Previous:first_app