Guiced Persistence gives you JTA with multi-datasource connection, and distributed connection handling through BTM.
This project exposes a Module DatabaseModule that you can extend to configure and connect your databases as you desire

You will need an annotation to identify the connection
public @interface MyDB {
Mark the requirement, and register your new module with the IGuiceModule service
module my.module {
    requires com.guicedee.guicedpersistence;
    provides IGuiceModule with DBModule;
A database module is needed to configure the connection, with overridable properties to alter it in any way
public class DBModule extends DatabaseModule<DBModule>
    protected @NotNull String getPersistenceUnitName()
        return "MyFirstPersistenceUnit";
    protected @NotNull ConnectionBaseInfo getConnectionBaseInfo(PersistenceUnit unit, Properties filteredProperties)
        return new BTMConnectionBaseInfo();
    protected @NotNull String getJndiMapping()
        return "jndi/jta/datasource";
    protected @NotNull Class<? extends Annotation> getBindingAnnotation()
        return MyDb.class;
Method Interception can specify which transaction to start on which database source. A Request Scoper is available to make each request into it's own unit of work for complete transaction control
@Transactional(entityManagerAnnotation = MyDb.class,timeout = 500)
public void me();
The request scoping addon can be added on by simply including the artifact, and adding it to your module-info file

Currently you can use the following ConnectionBaseInfo types (or your own)

  • BTMConnectionBaseInfo (JTA)
  • JPAConnectionBaseInfo (Non-Pooled JPA)
  • C3P0ConnectionBaseInfo (For Pooled JPA)
  • WildflyConnectionBaseInfo (For standalone files)

This module will bind (and log) the following bindings with the annotation as a key,