本文整理汇总了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);
}