use of org.hibernate.cfg.AttributeConverterDefinition in project hibernate-orm by hibernate.
the class EntityManagerFactoryBuilderImpl method populate.
protected void populate(MetadataBuilder metamodelBuilder, MergedSettings mergedSettings, StandardServiceRegistry ssr, List<AttributeConverterDefinition> attributeConverterDefinitions) {
if (persistenceUnit.getTempClassLoader() != null) {
metamodelBuilder.applyTempClassLoader(persistenceUnit.getTempClassLoader());
}
metamodelBuilder.applyScanEnvironment(new StandardJpaScanEnvironmentImpl(persistenceUnit));
metamodelBuilder.applyScanOptions(new StandardScanOptions((String) configurationValues.get(org.hibernate.cfg.AvailableSettings.SCANNER_DISCOVERY), persistenceUnit.isExcludeUnlistedClasses()));
if (mergedSettings.cacheRegionDefinitions != null) {
for (CacheRegionDefinition localCacheRegionDefinition : mergedSettings.cacheRegionDefinitions) {
metamodelBuilder.applyCacheRegionDefinition(localCacheRegionDefinition);
}
}
final TypeContributorList typeContributorList = (TypeContributorList) configurationValues.remove(TYPE_CONTRIBUTORS);
if (typeContributorList != null) {
for (TypeContributor typeContributor : typeContributorList.getTypeContributors()) {
metamodelBuilder.applyTypes(typeContributor);
}
}
if (attributeConverterDefinitions != null) {
for (AttributeConverterDefinition attributeConverterDefinition : attributeConverterDefinitions) {
metamodelBuilder.applyAttributeConverter(attributeConverterDefinition);
}
}
}
use of org.hibernate.cfg.AttributeConverterDefinition in project hibernate-orm by hibernate.
the class EntityManagerFactoryBuilderImpl method populate.
@SuppressWarnings("unchecked")
protected List<AttributeConverterDefinition> populate(MetadataSources metadataSources, MergedSettings mergedSettings, StandardServiceRegistry ssr) {
// final ClassLoaderService classLoaderService = ssr.getService( ClassLoaderService.class );
//
// // todo : make sure MetadataSources/Metadata are capable of handling duplicate sources
//
// // explicit persistence unit mapping files listings
// if ( persistenceUnit.getMappingFileNames() != null ) {
// for ( String name : persistenceUnit.getMappingFileNames() ) {
// metadataSources.addResource( name );
// }
// }
//
// // explicit persistence unit managed class listings
// // IMPL NOTE : managed-classes can contain class or package names!!!
// if ( persistenceUnit.getManagedClassNames() != null ) {
// for ( String managedClassName : persistenceUnit.getManagedClassNames() ) {
// // try it as a class name first...
// final String classFileName = managedClassName.replace( '.', '/' ) + ".class";
// final URL classFileUrl = classLoaderService.locateResource( classFileName );
// if ( classFileUrl != null ) {
// // it is a class
// metadataSources.addAnnotatedClassName( managedClassName );
// continue;
// }
//
// // otherwise, try it as a package name
// final String packageInfoFileName = managedClassName.replace( '.', '/' ) + "/package-info.class";
// final URL packageInfoFileUrl = classLoaderService.locateResource( packageInfoFileName );
// if ( packageInfoFileUrl != null ) {
// // it is a package
// metadataSources.addPackage( managedClassName );
// continue;
// }
//
// LOG.debugf(
// "Unable to resolve class [%s] named in persistence unit [%s]",
// managedClassName,
// persistenceUnit.getName()
// );
// }
// }
List<AttributeConverterDefinition> attributeConverterDefinitions = null;
// add any explicit Class references passed in
final List<Class> loadedAnnotatedClasses = (List<Class>) configurationValues.remove(AvailableSettings.LOADED_CLASSES);
if (loadedAnnotatedClasses != null) {
for (Class cls : loadedAnnotatedClasses) {
if (AttributeConverter.class.isAssignableFrom(cls)) {
if (attributeConverterDefinitions == null) {
attributeConverterDefinitions = new ArrayList<>();
}
attributeConverterDefinitions.add(AttributeConverterDefinition.from((Class<? extends AttributeConverter>) cls));
} else {
metadataSources.addAnnotatedClass(cls);
}
}
}
// add any explicit hbm.xml references passed in
final String explicitHbmXmls = (String) configurationValues.remove(AvailableSettings.HBXML_FILES);
if (explicitHbmXmls != null) {
for (String hbmXml : StringHelper.split(", ", explicitHbmXmls)) {
metadataSources.addResource(hbmXml);
}
}
// add any explicit orm.xml references passed in
final List<String> explicitOrmXmlList = (List<String>) configurationValues.remove(AvailableSettings.XML_FILE_NAMES);
if (explicitOrmXmlList != null) {
for (String ormXml : explicitOrmXmlList) {
metadataSources.addResource(ormXml);
}
}
return attributeConverterDefinitions;
}
use of org.hibernate.cfg.AttributeConverterDefinition in project hibernate-orm by hibernate.
the class ParameterizedAttributeConverterParameterTypeTest method testGenericTypeParameters.
@Test
@TestForIssue(jiraKey = "HHH-8804")
public void testGenericTypeParameters() {
AttributeConverterDefinition def = AttributeConverterDefinition.from(CustomAttributeConverter.class);
assertEquals(List.class, def.getEntityAttributeType());
}
use of org.hibernate.cfg.AttributeConverterDefinition in project hibernate-orm by hibernate.
the class AttributeConverterOnSuperclassTest method testAttributeConverterOnSuperclass.
@Test
public void testAttributeConverterOnSuperclass() {
AttributeConverterDefinition def = AttributeConverterDefinition.from(StringIntegerConverterSubclass.class);
assertEquals(String.class, def.getEntityAttributeType());
}
use of org.hibernate.cfg.AttributeConverterDefinition in project hibernate-orm by hibernate.
the class AttributeConverterOnSuperclassTest method testParameterizedTypeWithTypeVariableAttributeConverterTypeArguments.
@Test
public void testParameterizedTypeWithTypeVariableAttributeConverterTypeArguments() {
AttributeConverterDefinition def = AttributeConverterDefinition.from(StringListNoopAttributeConverter.class);
assertEquals(List.class, def.getEntityAttributeType());
}
Aggregations