本文整理汇总了Java中org.hibernate.cfg.Configuration.setInterceptor方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.setInterceptor方法的具体用法?Java Configuration.setInterceptor怎么用?Java Configuration.setInterceptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.setInterceptor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newSessionFactory
import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
private SessionFactory newSessionFactory() {
Properties properties = properties();
Configuration configuration = new Configuration().addProperties(properties);
for (Class<?> entityClass : entities()) {
configuration.addAnnotatedClass(entityClass);
}
String[] packages = packages();
if (packages != null) {
for (String scannedPackage : packages) {
configuration.addPackage(scannedPackage);
}
}
String[] resources = resources();
if (resources != null) {
for (String resource : resources) {
configuration.addResource(resource);
}
}
Interceptor interceptor = interceptor();
if (interceptor != null) {
configuration.setInterceptor(interceptor);
}
configuration.setProperties(properties);
return configuration.buildSessionFactory(
new BootstrapServiceRegistryBuilder()
.build()
);
}
示例2: newLegacySessionFactory
import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
private SessionFactory newLegacySessionFactory() {
Properties properties = properties();
Configuration configuration = new Configuration().addProperties(properties);
for (Class<?> entityClass : entities()) {
configuration.addAnnotatedClass(entityClass);
}
String[] packages = packages();
if (packages != null) {
for (String scannedPackage : packages) {
configuration.addPackage(scannedPackage);
}
}
String[] resources = resources();
if (resources != null) {
for (String resource : resources) {
configuration.addResource(resource);
}
}
Interceptor interceptor = interceptor();
if (interceptor != null) {
configuration.setInterceptor(interceptor);
}
final List<Type> additionalTypes = additionalTypes();
if (additionalTypes != null) {
configuration.registerTypeContributor((typeContributions, serviceRegistry) -> {
additionalTypes.stream().forEach(type -> {
if (type instanceof BasicType) {
typeContributions.contributeType((BasicType) type);
} else if (type instanceof UserType) {
typeContributions.contributeType((UserType) type);
} else if (type instanceof CompositeUserType) {
typeContributions.contributeType((CompositeUserType) type);
}
});
});
}
return configuration.buildSessionFactory(
new StandardServiceRegistryBuilder()
.applySettings(properties)
.build()
);
}
示例3: newSessionFactory
import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
private SessionFactory newSessionFactory() {
Properties properties = properties();
Configuration configuration = new Configuration().addProperties(properties);
for (Class<?> entityClass : entities()) {
configuration.addAnnotatedClass(entityClass);
}
String[] packages = packages();
if (packages != null) {
for (String scannedPackage : packages) {
configuration.addPackage(scannedPackage);
}
}
String[] resources = resources();
if (resources != null) {
for (String resource : resources) {
configuration.addResource(resource);
}
}
Interceptor interceptor = interceptor();
if (interceptor != null) {
configuration.setInterceptor(interceptor);
}
final List<Type> additionalTypes = additionalTypes();
if (additionalTypes != null) {
configuration.registerTypeContributor(new TypeContributor() {
@Override
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
for (Type type : additionalTypes) {
if (type instanceof BasicType) {
typeContributions.contributeType((BasicType) type);
} else if (type instanceof UserType) {
typeContributions.contributeType((UserType) type, new String[]{type.getName()});
} else if (type instanceof CompositeUserType) {
typeContributions.contributeType((CompositeUserType) type, new String[]{type.getName()});
}
}
}
});
}
return configuration.buildSessionFactory(
new StandardServiceRegistryBuilder()
.applySettings(properties)
.build()
);
}
示例4: newLegacySessionFactory
import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
private SessionFactory newLegacySessionFactory() {
Properties properties = properties();
Configuration configuration = new Configuration().addProperties(properties);
for (Class<?> entityClass : entities()) {
configuration.addAnnotatedClass(entityClass);
}
String[] packages = packages();
if (packages != null) {
for (String scannedPackage : packages) {
configuration.addPackage(scannedPackage);
}
}
String[] resources = resources();
if (resources != null) {
for (String resource : resources) {
configuration.addResource(resource);
}
}
Interceptor interceptor = interceptor();
if (interceptor != null) {
configuration.setInterceptor(interceptor);
}
final List<Type> additionalTypes = additionalTypes();
if (additionalTypes != null) {
configuration.registerTypeContributor(new TypeContributor() {
@Override
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
for (Type type : additionalTypes) {
if (type instanceof BasicType) {
typeContributions.contributeType((BasicType) type);
} else if (type instanceof UserType) {
typeContributions.contributeType((UserType) type);
} else if (type instanceof CompositeUserType) {
typeContributions.contributeType((CompositeUserType) type);
}
}
}
});
}
return configuration.buildSessionFactory(
new StandardServiceRegistryBuilder()
.applySettings(properties)
.build()
);
}