Skip to content

olivas-bo/persistence-base

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

persistence-base Build Status

Why did I build this?

In my post-graduation classes, I had to build a lot of simple projects with only persistence in one grade. So, I build this because I'm lazy.

Tecnology

This project is built on top of the following tecnologies:

  • EclipseLink and JPA2

    EclipseLink is the reference implementation of JPA2 (JSR-317) specification. I also found it a bit faster and "ligher" than other ORMs, like Hibernate.

  • Apache B-Val

    Implementation (not sure if is the reference one) of the JSR-303, which a meta-data model and API for JavaBeanTM validation based on defines annotations, with overrides and extended meta-data through the use of XML validation descriptors."

  • Google Guice

    Reference Implementation of the JSR-330, which helps "to maximize reusability, testability and maintainability of Java code by standardizing an extensible dependency injection API".

  • Google Guava APIs

    A set of utility classes to made you write less code. You might want to take a loot at this.

  • JUnit

    For tests pourposes.

  • Apache Maven

    You know that it is.

What we provide

We provide a set of useful classes which you can use to bootstrap your persistence project:

  • A MappedSuperclass with @Id and @Version (see the Bean class);
  • A MappedSuperclass with @Id and @Version and updated_at and created_at columns, just like Rails (see the TimestampedBean class);
  • A GenericDao that provide basic CRUD operations out of the box;
  • An AbstractPersistentModule to you extend and do things like:
// module setup
bindGenericDaoFor(MyBean.class);

And guice will automagically provide a GenericDao<MyBean> to you, so you can inject like this:

// some class
@Inject Dao<MyBean> myBeanDao;

You can also do something like

bind(MyOtherDao.class).to(MyOtherBeanDaoImpl.class);

in your module, and then, somewhere, just inject it:

@Inject MyOtherDao myOtherDao;

And then use it like a boss.

The AbstractPersistentModule will also startup the PersistenceService (Guice-Persist setup).

How-to use

Please, read this post about persistence-base

I would also recommend you to read the sources of the tests. It's a complete basic example, you should use it as a "light" for you.

Recommended use

You can use this project as a base for you school project, or any other app. I'll recommend you to read the sources, and, change anything to adapts to what you may need.

For school projects, it should be good enought in it's actual state. Just clone, rename and put the horses to work on what really matter.


You might want to take a look at this old tutorial of an old revision of this project (you may want to use it at 0.0.1 tag).

About

A base persistence project with Maven, Eclipse-Link, Apache B-Val, Guice and Guice-Persist.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors