Skip to main content

Posts

Showing posts with the label JPA

JPA service generalization, templeting

JPA made small revolution among ORM tools and EJB 2 world. Easy to use, simple unified way to develop you model and services. After i used it in few projects, i have found that all JPA services are very similar, so this is a simple try to generalize or template them. This can be for example simple abstract interface for all: package test . service ; import java.util.List ; public abstract interface JpaService < T > { void save ( T t ); T find ( Long id ); void remove ( Long id ); List < T > findAll (); long count (); } And abstract implementation class look like this: package test . service . impl ; import java.util.List ; import javax.persistence.EntityManager ; import javax.persistence.PersistenceContext ; import javax.persistence.Query ; import org.apache.log4j.Logger ; import test.service.JpaService ; public abstract class JpaServiceImpl < T > implements JpaService < T >{ /** Logger. */ ...

Use JPA with MongoDb and Datanucleus

Web applications nowadays have huge demand for data processing, and they need to get them, process them, and displayed them fast. Traditional relational tables and big SQL engines fail to serve that purpose. NoSQL movement is on the rise. There are huge numbers of alternatives to SQL like BigTable, HBase, CouchDB, Cassandra and MongoDB. They are all fast but you'll need to implement new way to work with them, since all of them have they own query languages. It would be nice that we can use them in similar or same way in our projects, after all ORM layer is there for that to decouple our objects from underlying storage. MongoDB is one of most popular NoSQL solutions and easiest one to install. For HBase i would had to install cygwin or virtual linux, and still will be hard to confgiure it right. MongoDb is easy, it plays out of the box, just unzip it, and it still offers some nice features like MapReduce, Replication and Sharding. Datanucleus is one of the leading ORM provid...