org.hibernate.cfg.Configuration.addFile()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.hibernate.cfg.Configuration.addFile()方法的一些代码示例,展示了Configuration.addFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.addFile()方法的具体详情如下:
包路径:org.hibernate.cfg.Configuration
类名称:Configuration
方法名:addFile

Configuration.addFile介绍

[英]Read mappings from a particular XML file
[中]从特定XML文件读取映射

代码示例

代码示例来源:origin: hibernate/hibernate-orm

protected void initMappings() throws MappingException, URISyntaxException {
  URL url = Thread.currentThread().getContextClassLoader().getResource(
      "mappings/entityNames/manyToManyAudited/mappings.hbm.xml"
  );
  config.addFile( new File( url.toURI() ) );
}

代码示例来源:origin: hibernate/hibernate-orm

protected void initMappings() throws MappingException, URISyntaxException {
  URL url = Thread.currentThread().getContextClassLoader().getResource(
      "mappings/entityNames/oneToManyNotAudited/mappings.hbm.xml"
  );
  config.addFile( new File( url.toURI() ) );
}

代码示例来源:origin: hibernate/hibernate-orm

protected void initMappings() throws MappingException, URISyntaxException {
  URL url = Thread.currentThread().getContextClassLoader().getResource(
      "mappings/entityNames/oneToManyAudited/mappings.hbm.xml"
  );
  config.addFile( new File( url.toURI() ) );
}

代码示例来源:origin: hibernate/hibernate-orm

protected void initMappings() throws MappingException, URISyntaxException {
  URL url = Thread.currentThread().getContextClassLoader().getResource(
      "mappings/entityNames/singleAssociatedAudited/mappings.hbm.xml"
  );
  config.addFile( new File( url.toURI() ) );
}

代码示例来源:origin: hibernate/hibernate-orm

protected void initMappings() throws MappingException, URISyntaxException {
  URL url = Thread.currentThread().getContextClassLoader().getResource(
      "mappings/entityNames/manyToManyAudited/mappings.hbm.xml"
  );
  config.addFile( new File( url.toURI() ) );
}

代码示例来源:origin: hibernate/hibernate-orm

protected void initMappings() throws MappingException, URISyntaxException {
  URL url = Thread.currentThread().getContextClassLoader().getResource(
      "mappings/entityNames/singleAssociatedNotAudited/mappings.hbm.xml"
  );
  config.addFile( new File( url.toURI() ) );
}

代码示例来源:origin: hibernate/hibernate-orm

protected void initMappings() throws MappingException, URISyntaxException {
  URL url = Thread.currentThread().getContextClassLoader().getResource(
      "mappings/entityNames/singleAssociatedAudited/mappings.hbm.xml"
  );
  config.addFile( new File( url.toURI() ) );
}

代码示例来源:origin: hibernate/hibernate-orm

protected void initMappings() throws MappingException, URISyntaxException {
  URL url = Thread.currentThread().getContextClassLoader().getResource(
      "mappings/entityNames/auditedEntity/mappings.hbm.xml"
  );
  config.addFile( new File( url.toURI() ) );
}

代码示例来源:origin: hibernate/hibernate-orm

public void testAuditedDynamicComponentFailure() throws URISyntaxException {
  final Configuration config = new Configuration();
  final URL hbm = Thread.currentThread().getContextClassLoader().getResource(
      "mappings/dynamicComponents/mapAudited.hbm.xml"
  );
  config.addFile( new File( hbm.toURI() ) );
  final String auditStrategy = getAuditStrategy();
  if ( !StringTools.isEmpty( auditStrategy ) ) {
    config.setProperty( EnversSettings.AUDIT_STRATEGY, auditStrategy );
  }
  final ServiceRegistry serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( config.getProperties() );
  try {
    config.buildSessionFactory( serviceRegistry );
    Assert.fail( "MappingException expected" );
  }
  catch ( MappingException e ) {
    Assert.assertEquals(
        "Audited dynamic-component properties are not supported. Consider applying @NotAudited annotation to "
            + AuditedDynamicComponentEntity.class.getName() + "#customFields.",
        e.getMessage()
    );
  }
  finally {
    ServiceRegistryBuilder.destroy( serviceRegistry );
  }
}

代码示例来源:origin: org.hibernate/hibernate-annotations

@Override
public AnnotationConfiguration addFile(String xmlFile) throws MappingException {
  super.addFile( xmlFile );
  return this;
}

代码示例来源:origin: org.hibernate/hibernate-annotations

@Override
public AnnotationConfiguration addFile(File xmlFile) throws MappingException {
  super.addFile( xmlFile );
  return this;
}

代码示例来源:origin: hibernate/hibernate-orm

cfg.addFile( file.getAbsolutePath() );
fail();
cfg.addFile( file );
fail();

代码示例来源:origin: hibernate/hibernate-orm

cfg.addFile( "completelybogus.hbm.xml" );
fail();
cfg.addFile( new File( "completelybogus.hbm.xml" ) );
fail();

代码示例来源:origin: org.jbpm/pvm

public void apply(Object target, WireContext wireContext) {
 Configuration configuration = (Configuration) target;
 configuration.addFile(fileName);
}
public String toString() {

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

@Override
public AnnotationConfiguration addFile(File xmlFile) throws MappingException {
  super.addFile( xmlFile );
  return this;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

@Override
public AnnotationConfiguration addFile(String xmlFile) throws MappingException {
  super.addFile( xmlFile );
  return this;
}

代码示例来源:origin: org.ow2.bonita/bonita-server

@Override
public void apply(final Object target, final WireContext wireContext) {
 final Configuration configuration = (Configuration) target;
 configuration.addFile(fileName);
}

代码示例来源:origin: babyfish-ct/babyfish

@Override
public Configuration addFile(String xmlFile) throws MappingException {
  super.addFile(xmlFile);
  return this;
}

代码示例来源:origin: babyfish-ct/babyfish

@Override
public Configuration addFile(File xmlFile) throws MappingException {
  super.addFile(xmlFile);
  return this;
}

代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate

private static boolean addMappingFilesToConfiguration(final Configuration cfg) {
  boolean haveReadAMappingFile = false;
  NakedObjectConfiguration config = NakedObjectsContext.getConfiguration();
  final String path = config.getString(PROPERTY_PREFIX + "hbm-export", config.rootPath() + FILE_SEPERATOR + MAPPING_DIR);
  final List<File> mappingFiles = readMappingFiles(path);
  for (final File file : mappingFiles) {
    cfg.addFile(file);
    haveReadAMappingFile = true;
    LOG.info("reading mapping file: " + file.getAbsolutePath());
  }
  return haveReadAMappingFile;
}

相关文章

Configuration类方法