List of usage examples for org.hibernate.cfg Configuration Configuration
public Configuration()
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);//from ww w . j av a2 s . co m HibernateDomainExporter exporter = new HibernateDomainExporter("Q", new File("target/gen2"), config); exporter.execute(); 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_Multiple() throws IOException { FileUtils.delete(new File("target/gen3")); Configuration config = new Configuration(); for (Class<?> cl : Domain.classes) { config.addAnnotatedClass(cl);//from w ww. j a va 2s .c o m } HibernateDomainExporter exporter = new HibernateDomainExporter("Q", new File("target/gen3"), serializerConfig, config); exporter.execute(); List<String> failures = new ArrayList<String>(); for (File file : new File("target/gen3/com/querydsl/jpa/domain").listFiles()) { String result1 = Files.toString(file, Charsets.UTF_8); String result2 = Files .toString(new File("../querydsl-jpa/target/generated-test-sources/java/com/querydsl/jpa/domain", file.getName()), Charsets.UTF_8); if (!result1.equals(result2)) { System.err.println(file.getName()); failures.add(file.getName()); } } if (!failures.isEmpty()) { fail("Failed with " + failures.size() + " failures"); } CompileUtils.compile("target/gen3"); }
From source file:com.querydsl.jpa.codegen.HibernateDomainExporterTest.java
License:Apache License
@Test public void Execute_Multiple2() throws IOException { FileUtils.delete(new File("target/gen4")); Configuration config = new Configuration(); for (Class<?> cl : Domain2.classes) { config.addAnnotatedClass(cl);// w w w . j a v a 2 s . c o m } HibernateDomainExporter exporter = new HibernateDomainExporter("Q", new File("target/gen4"), serializerConfig, config); exporter.execute(); List<String> failures = new ArrayList<String>(); for (File file : new File("target/gen4/com/querydsl/jpa/domain2").listFiles()) { String result1 = Files.toString(file, Charsets.UTF_8); String result2 = Files.toString( new File("../querydsl-jpa/target/generated-test-sources/java/com/querydsl/jpa/domain2", file.getName()), Charsets.UTF_8); if (!result1.equals(result2)) { System.err.println(file.getName()); failures.add(file.getName()); } } if (!failures.isEmpty()) { fail("Failed with " + failures.size() + " failures"); } CompileUtils.compile("target/gen4"); }
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);/*from w w w . j av a 2s. com*/ HibernateDomainExporter exporter = new HibernateDomainExporter("Q", new File("target/gen5"), config); exporter.execute(); 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 w ww .jav a 2 s . co m exporter.execute(); CompileUtils.compile("target/gen18"); }
From source file:com.querydsl.jpa.codegen.JPADomainExporterTest.java
License:Apache License
@Test @Ignore // FIXME/* w w w . j a v a 2 s.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"); }
From source file:com.querydsl.jpa.codegen.JPADomainExporterTest.java
License:Apache License
@Test public void Execute_Contact() throws IOException { FileUtils.delete(new File("target/jpagen1")); File contact = new File("src/test/resources/contact.hbm.xml"); Configuration config = new Configuration(); config.addFile(contact);//from w ww . j a v a2s . c om JPADomainExporter exporter = new JPADomainExporter("Q", new File("target/jpagen1"), convert(config)); exporter.execute(); File targetFile = new File("target/jpagen1/com/querydsl/jpa/domain2/QContact.java"); assertContains(targetFile, "StringPath email", "StringPath firstName", "NumberPath<Long> id", "StringPath lastName"); }
From source file:com.querydsl.jpa.codegen.JPADomainExporterTest.java
License:Apache License
@Test public void Execute_Contact_with_Suffix() throws IOException { FileUtils.delete(new File("target/jpagen1")); File contact = new File("src/test/resources/contact.hbm.xml"); Configuration config = new Configuration(); config.addFile(contact);/*from w w w . ja va 2 s . c o m*/ JPADomainExporter exporter = new JPADomainExporter("", "Type", new File("target/jpagen1"), convert(config)); exporter.execute(); File targetFile = new File("target/jpagen1/com/querydsl/jpa/domain2/ContactType.java"); assertContains(targetFile, "StringPath email", "StringPath firstName", "NumberPath<Long> id", "StringPath lastName"); }
From source file:com.querydsl.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);/*from ww w . ja v a2 s.co m*/ JPADomainExporter exporter = new JPADomainExporter("Q", new File("target/jpagen2"), convert(config)); exporter.execute(); File targetFile = new File("target/jpagen2/com/querydsl/jpa/domain2/QContact.java"); assertContains(targetFile, "StringPath email", "StringPath firstName", "NumberPath<Long> id", "StringPath lastName"); }
From source file:com.querydsl.jpa.codegen.JPADomainExporterTest.java
License:Apache License
@Test public void Execute_Multiple() throws IOException { FileUtils.delete(new File("target/jpagen3")); Configuration config = new Configuration(); for (Class<?> cl : Domain.classes) { config.addAnnotatedClass(cl);/* w w w. java 2 s .c o m*/ } JPADomainExporter exporter = new JPADomainExporter("Q", new File("target/jpagen3"), serializerConfig, convert(config)); exporter.execute(); List<String> failures = new ArrayList<String>(); for (File file : new File("target/jpagen3/com/querydsl/jpa/domain").listFiles()) { String result1 = Files.toString(file, Charsets.UTF_8); String result2 = Files .toString(new File("../querydsl-jpa/target/generated-test-sources/java/com/querydsl/jpa/domain", file.getName()), Charsets.UTF_8); if (!result1.equals(result2)) { System.err.println(file.getName()); failures.add(file.getName()); } } failures.remove("QCalendar.java"); // FIXME if (!failures.isEmpty()) { fail("Failed with " + failures.size() + " failures"); } }