Example usage for org.hibernate.cfg Configuration addFile

List of usage examples for org.hibernate.cfg Configuration addFile

Introduction

In this page you can find the example usage for org.hibernate.cfg Configuration addFile.

Prototype

public Configuration addFile(File xmlFile) throws MappingException 

Source Link

Document

Read mappings from a particular XML file

Usage

From source file:com.mysema.query.jpa.codegen.JPADomainExporterTest.java

License:Apache License

@Test
public void Execute_Contact2() throws IOException {
    FileUtils.delete(new File("target/jpagen2"));
    File contact = new File("src/test/resources/contact2.hbm.xml");
    Configuration config = new Configuration();
    config.addFile(contact);
    JPADomainExporter exporter = new JPADomainExporter("Q", new File("target/jpagen2"), convert(config));
    exporter.execute();/*from w  w  w  . ja v  a2s  .c  o  m*/

    File targetFile = new File("target/jpagen2/com/mysema/query/jpa/domain2/QContact.java");
    assertContains(targetFile, "StringPath email", "StringPath firstName", "NumberPath<Long> id",
            "StringPath lastName");
}

From source file:com.mysema.query.jpa.codegen.JPADomainExporterTest.java

License:Apache License

@Test
@Ignore // FIXME//from  w w w . j av a  2  s.com
public void Execute_Store() throws IOException {
    FileUtils.delete(new File("target/jpagen5"));
    File contact = new File("src/test/resources/store.hbm.xml");
    Configuration config = new Configuration();
    config.addFile(contact);
    JPADomainExporter exporter = new JPADomainExporter("Q", new File("target/jpagen5"), convert(config));
    exporter.execute();

    File targetFile = new File("target/jpagen5/com/mysema/query/jpa/domain3/QStore.java");
    assertContains(targetFile, "StringPath code", "StringPath address");

    targetFile = new File("target/jpagen5/com/mysema/query/jpa/domain3/QHardwareStore.java");
    assertContains(targetFile, "StringPath code = _super.code;", "StringPath address");
}

From source file:com.oy.shared.lm.ext.HBMCtoGRAPH.java

License:Open Source License

public static IGraphModel load(TaskOptions options) throws IOException {
    Configuration conf = new Configuration();

    // add all documents to Configuration
    for (int i = 0; i < options.inFileSet.length; i++) {
        conf.addFile(options.inFileSet[i]);
    }//from w  ww.j a va 2 s .c  om

    return new HBMCtoGRAPH().innerLoad(options, conf);
}

From source file:com.querydsl.jpa.codegen.HibernateDomainExporterTest.java

License:Apache License

@Test
public void Execute_MyEntity() throws IOException {
    FileUtils.delete(new File("target/gen6"));
    File myEntity = new File("src/test/resources/entity.hbm.xml");
    Configuration config = new Configuration();
    config.addFile(myEntity);
    HibernateDomainExporter exporter = new HibernateDomainExporter("Q", new File("target/gen6"), config);
    exporter.execute();//  w  w w  . j  a  v  a 2 s . c o  m

    File targetFile = new File("target/gen6/com/querydsl/jpa/codegen/QMyEntity.java");
    assertContains(targetFile, "StringPath pk1", "StringPath pk2", "StringPath prop1");

    CompileUtils.compile("target/gen6");
}

From source file:com.querydsl.jpa.codegen.HibernateDomainExporterTest.java

License:Apache License

@Test
public void Execute_Contact() throws IOException {
    FileUtils.delete(new File("target/gen1"));
    File contact = new File("src/test/resources/contact.hbm.xml");
    Configuration config = new Configuration();
    config.addFile(contact);
    HibernateDomainExporter exporter = new HibernateDomainExporter("Q", new File("target/gen1"), config);
    exporter.execute();// ww w .j a  v  a  2 s  .co  m

    File targetFile = new File("target/gen1/com/querydsl/jpa/domain2/QContact.java");
    assertContains(targetFile, "StringPath email", "StringPath firstName", "NumberPath<Long> id",
            "StringPath lastName");

    CompileUtils.compile("target/gen1");
}

From source file:com.querydsl.jpa.codegen.HibernateDomainExporterTest.java

License:Apache License

@Test
public void Execute_Contact_with_Suffix() throws IOException {
    FileUtils.delete(new File("target/gen1"));
    File contact = new File("src/test/resources/contact.hbm.xml");
    Configuration config = new Configuration();
    config.addFile(contact);
    HibernateDomainExporter exporter = new HibernateDomainExporter("", "Type", new File("target/gen1"), config);
    exporter.execute();//w  w  w.j  a v  a  2  s .  c  om

    File targetFile = new File("target/gen1/com/querydsl/jpa/domain2/ContactType.java");
    assertContains(targetFile, "StringPath email", "StringPath firstName", "NumberPath<Long> id",
            "StringPath lastName");

    CompileUtils.compile("target/gen1");
}

From source file:com.querydsl.jpa.codegen.HibernateDomainExporterTest.java

License:Apache License

@Test
public void Execute_Contact2() throws IOException {
    FileUtils.delete(new File("target/gen2"));
    File contact = new File("src/test/resources/contact2.hbm.xml");
    Configuration config = new Configuration();
    config.addFile(contact);
    HibernateDomainExporter exporter = new HibernateDomainExporter("Q", new File("target/gen2"), config);
    exporter.execute();//from   www  . j a va 2 s .c o  m

    File targetFile = new File("target/gen2/com/querydsl/jpa/domain2/QContact.java");
    assertContains(targetFile, "StringPath email", "StringPath firstName", "NumberPath<Long> id",
            "StringPath lastName");

    CompileUtils.compile("target/gen2");
}

From source file:com.querydsl.jpa.codegen.HibernateDomainExporterTest.java

License:Apache License

@Test
public void Execute_Store() throws IOException {
    FileUtils.delete(new File("target/gen5"));
    File contact = new File("src/test/resources/store.hbm.xml");
    Configuration config = new Configuration();
    config.addFile(contact);
    HibernateDomainExporter exporter = new HibernateDomainExporter("Q", new File("target/gen5"), config);
    exporter.execute();/*from   w w w . j a  v  a 2  s .com*/

    File targetFile = new File("target/gen5/com/querydsl/jpa/domain3/QStore.java");
    assertContains(targetFile, "StringPath code", "StringPath address");

    targetFile = new File("target/gen5/com/querydsl/jpa/domain3/QHardwareStore.java");
    assertContains(targetFile, "StringPath code = _super.code;", "StringPath address");

    CompileUtils.compile("target/gen5");
}

From source file:com.querydsl.jpa.codegen.HibernateDomainExporterTest.java

License:Apache License

@Test
public void Execute_CompositeKey() throws IOException {
    // See https://github.com/querydsl/querydsl/issues/1459

    FileUtils.delete(new File("target/gen18"));

    Configuration config = new Configuration();
    config.addFile(new File("src/test/resources/route1.hbm.xml"));
    config.addFile(new File("src/test/resources/route2.hbm.xml"));
    HibernateDomainExporter exporter = new HibernateDomainExporter("Q", new File("target/gen18"),
            serializerConfig, config);//from  www.  jav a  2 s  . c o  m
    exporter.execute();

    CompileUtils.compile("target/gen18");
}

From source file:com.querydsl.jpa.codegen.JPADomainExporterTest.java

License:Apache License

@Test
@Ignore // FIXME/* ww  w.j  a va 2s  . c  o m*/
public void Execute_MyEntity() throws IOException {
    FileUtils.delete(new File("target/jpagen6"));
    File myEntity = new File("src/test/resources/entity.hbm.xml");
    Configuration config = new Configuration();
    config.addFile(myEntity);
    JPADomainExporter exporter = new JPADomainExporter("Q", new File("target/jpagen6"), convert(config));
    exporter.execute();

    File targetFile = new File("target/jpagen6/com/querydsl/jpa/codegen/QMyEntity.java");
    assertContains(targetFile, "StringPath pk1", "StringPath pk2", "StringPath prop1");
}