microBean JPA (Weld SE)
The microBean JPA (Weld SE) project brings JPA to standalone, Weld-based, CDI 2.0 programs.
If you are programming in an environment that already has JPA, such as a Java EE application server, then this project is not for you.
If you are writing a Java SE program using CDI, then this project may very well be for you.
This project works in conjunction with the microBean JPA CDI Extension CDI portable extension. The portable extension handles the truly portable aspects of bringing JPA to CDI—and this project completes the process with an implementation of Weld's JpaInjectionServices
service provider interface. When the two of these projects are used together, then in terms of end-user-observable effects you can do the following:
public class MyCDIBean {
@PersistenceContext(unitName = "dev")
private EntityManager em;
}
That is, you can inject an EntityManager
as though your Weld-based standalone CDI 2.0 Java SE program were in fact a Java EE application server (at least with respect to JPA).
This extension is often used in conjunction with the microBean JPA CDI Extension project, the microBean Narayana JTA CDI Extension project and its Weld variant and the microBean DataSource CDI HikariCP Extension.
When you put all these components on your classpath, then any EntityManager
injected by being annotated with @PersistenceContext
that is involved in the execution of any method annotated with @Transactional
will automatically join an automatically-created JTA Transaction
, managed by the Narayana transaction engine. The result is EJB-like behavior without an EJB container or application server.
If you have an implementation of Bean Validation on your classpath, then it will be incorporated into this project's overall JPA support as well.