本文整理了Java中org.hibernate.cfg.Configuration.addResource()
方法的一些代码示例,展示了Configuration.addResource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.addResource()
方法的具体详情如下:
包路径:org.hibernate.cfg.Configuration
类名称:Configuration
方法名:addResource
[英]Read mappings as a application resourceName (i.e. classpath lookup) trying different class loaders.
[中]尝试不同的类加载器,将映射作为应用程序资源名读取(即类路径查找)。
代码示例来源:origin: hibernate/hibernate-orm
/**
* @deprecated This form (accepting a ClassLoader) is no longer supported. Instead, add the ClassLoader
* to the ClassLoaderService on the ServiceRegistry associated with this Configuration
*/
@Deprecated
public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
return addResource( resourceName );
}
代码示例来源:origin: hibernate/hibernate-orm
protected final Configuration buildConfiguration() {
Configuration cfg = new Configuration().setProperties( buildProperties() );
String[] mappingFiles = ConfigurationHelper.toStringArray( mapResources, " ,\n\t\r\f" );
for ( int i = 0; i < mappingFiles.length; i++ ) {
cfg.addResource( mappingFiles[i] );
}
return cfg;
}
代码示例来源:origin: hibernate/hibernate-orm
if ( mappings != null ) {
for ( String mapping : mappings ) {
configuration.addResource(
getBaseForMappings() + mapping,
getClass().getClassLoader()
代码示例来源:origin: hibernate/hibernate-orm
private Configuration buildBaseConfiguration() {
return new Configuration()
.addResource( "org/hibernate/test/stats/Continent.hbm.xml" )
.setProperty( AvailableSettings.GENERATE_STATISTICS, "true" );
}
//
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testFirstTypeThenEntity(){
cfg.addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml")
.addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml");
SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry);
Assert.assertNotNull(sessions);
sessions.close();
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testFirstEntityThenType(){
cfg.addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml")
.addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml");
SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry);
Assert.assertNotNull(sessions);
sessions.close();
}
代码示例来源:origin: org.hibernate/hibernate-annotations
@Override
public AnnotationConfiguration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
super.addResource( resourceName, classLoader );
return this;
}
代码示例来源:origin: org.hibernate/hibernate-annotations
@Override
public AnnotationConfiguration addResource(String resourceName) throws MappingException {
super.addResource( resourceName );
return this;
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testDuplicateEntityName() throws Exception {
Configuration cfg = new Configuration();
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
ServiceRegistry serviceRegistry = null;
SessionFactory sf = null;
try {
cfg.addAnnotatedClass( Flight.class );
cfg.addAnnotatedClass( org.hibernate.test.annotations.Flight.class );
cfg.addAnnotatedClass( org.hibernate.test.annotations.Company.class );
cfg.addResource( "org/hibernate/test/annotations/orm.xml" );
cfg.addResource( "org/hibernate/test/annotations/duplicatedgenerator/orm.xml" );
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
sf = cfg.buildSessionFactory( serviceRegistry );
Assert.fail( "Should not be able to map the same entity name twice" );
}
catch (DuplicateMappingException ae) {
//success
}
finally {
if (sf != null){
sf.close();
}
if ( serviceRegistry != null ) {
ServiceRegistryBuilder.destroy( serviceRegistry );
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
cfg.addResource( resourceName );
fail();
cfg.addResource( resourceName, getClass().getClassLoader() );
fail();
代码示例来源:origin: hibernate/hibernate-orm
cfg.addResource( "nothere" );
fail();
cfg.addResource( "nothere", getClass().getClassLoader() );
fail();
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
@Override
public AnnotationConfiguration addResource(String resourceName) throws MappingException {
super.addResource( resourceName );
return this;
}
代码示例来源:origin: babyfish-ct/babyfish
@Override
public Configuration addResource(String resourceName,
ClassLoader classLoader) throws MappingException {
super.addResource(resourceName, classLoader);
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
@Override
public AnnotationConfiguration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
super.addResource( resourceName, classLoader );
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
@Override
public AnnotationConfiguration addResource(String resourceName) throws MappingException {
super.addResource( resourceName );
return this;
}
代码示例来源:origin: org.ow2.bonita/bonita-server
@Override
public void apply(final Object target, final WireContext wireContext) {
final Configuration configuration = (Configuration) target;
configuration.addResource(resource, wireContext.getClassLoader());
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
protected final Configuration buildConfiguration() {
Configuration cfg = new Configuration().setProperties( buildProperties() );
String[] mappingFiles = ConfigurationHelper.toStringArray( mapResources, " ,\n\t\r\f" );
for ( int i = 0; i < mappingFiles.length; i++ ) {
cfg.addResource( mappingFiles[i] );
}
return cfg;
}
代码示例来源:origin: bonitasoft/bonita-engine
protected Configuration buildConfiguration(final Properties properties, final HibernateResourcesConfigurationProvider hibernateResourcesConfigurationProvider) {
final Configuration configuration = new Configuration();
configuration.addProperties(properties);
for (final String resource : hibernateResourcesConfigurationProvider.getResources()) {
configuration.addResource(resource);
}
configuration.buildMappings();
return configuration;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
protected final Configuration buildConfiguration() {
Configuration cfg = new Configuration().setProperties( buildProperties() );
String[] mappingFiles = ConfigurationHelper.toStringArray( mapResources, " ,\n\t\r\f" );
for ( int i = 0; i < mappingFiles.length; i++ ) {
cfg.addResource( mappingFiles[i] );
}
return cfg;
}
代码示例来源:origin: org.hibernate.orm/hibernate-core
protected final Configuration buildConfiguration() {
Configuration cfg = new Configuration().setProperties( buildProperties() );
String[] mappingFiles = ConfigurationHelper.toStringArray( mapResources, " ,\n\t\r\f" );
for ( int i = 0; i < mappingFiles.length; i++ ) {
cfg.addResource( mappingFiles[i] );
}
return cfg;
}
内容来源于网络,如有侵权,请联系作者删除!