本文整理匯總了Java中org.jboss.shrinkwrap.descriptor.api.persistence.PersistenceUnitCommon類的典型用法代碼示例。如果您正苦於以下問題:Java PersistenceUnitCommon類的具體用法?Java PersistenceUnitCommon怎麽用?Java PersistenceUnitCommon使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PersistenceUnitCommon類屬於org.jboss.shrinkwrap.descriptor.api.persistence包,在下文中一共展示了PersistenceUnitCommon類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupConnection
import org.jboss.shrinkwrap.descriptor.api.persistence.PersistenceUnitCommon; //導入依賴的package包/類
@Override
public PersistenceUnitCommon setupConnection(PersistenceUnitCommon unit, JPADataSource dataSource) {
unit.transactionType("JTA");
if (dataSource.getDatabase() == null)
{
dataSource.setDatabase(DatabaseType.H2);
}
return unit;
}
示例2: initializeUI
import org.jboss.shrinkwrap.descriptor.api.persistence.PersistenceUnitCommon; //導入依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initializeUI(UIBuilder builder) throws Exception
{
UIContext context = builder.getUIContext();
Project project = getSelectedProject(context);
JPAFacet<PersistenceCommonDescriptor> persistenceFacet = project.getFacet(JPAFacet.class);
JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class);
List<String> persistenceUnits = new ArrayList<>();
List<PersistenceUnitCommon> allUnits = persistenceFacet.getConfig().getAllPersistenceUnit();
for (PersistenceUnitCommon persistenceUnit : allUnits)
{
persistenceUnits.add(persistenceUnit.getName());
}
if (!persistenceUnits.isEmpty())
{
persistenceUnit.setValueChoices(persistenceUnits).setDefaultValue(persistenceUnits.get(0));
}
// TODO: May detect where @Path resources are located
packageName.setDefaultValue(javaSourceFacet.getBasePackage() + ".rest");
RestResourceGenerator defaultResourceGenerator = null;
for (RestResourceGenerator generator : resourceGenerators)
{
if (generator.getName().equals(RestGenerationConstants.JPA_ENTITY))
{
defaultResourceGenerator = generator;
}
}
generator.setDefaultValue(defaultResourceGenerator);
generator.setItemLabelConverter(
context.getProvider().isGUI() ? RestResourceGenerator::getDescription : RestResourceGenerator::getName);
builder.add(generator).add(packageName).add(persistenceUnit);
}