{
installPersistence();
PersistenceFacet jpa = project.getFacet(PersistenceFacet.class);
PersistenceDescriptor config = jpa.getConfig();
PersistenceUnitDef unit = config.persistenceUnit(unitName);
unit.name(unitName).description(DEFAULT_UNIT_DESC);
PersistenceContainer container = jpac.getContainer(manager);
PersistenceProvider provider = jpap.getProvider(manager);
JPADataSource ds = new JPADataSource()
.setJndiDataSource(jtaDataSource)
.setDatabaseType(databaseType)
.setJdbcDriver(jdbcDriver)
.setDatabaseURL(jdbcURL)
.setUsername(jdbcUsername)
.setPassword(jdbcPassword)
.setContainer(container)
.setProvider(provider);
unit.transactionType(container.getTransactionType());
unit.provider(provider.getProvider());
container.setupConnection(unit, ds);
provider.configure(unit, ds);
jpa.saveConfig(config);