List of usage examples for org.hibernate.cfg Configuration addFile
public Configuration addFile(File xmlFile) throws MappingException
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); JPADomainExporter exporter = new JPADomainExporter("Q", new File("target/jpagen1"), convert(config)); exporter.execute();/*from ww w . ja v a 2 s . co m*/ 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); JPADomainExporter exporter = new JPADomainExporter("", "Type", new File("target/jpagen1"), convert(config)); exporter.execute();//from w w w . ja v a2 s. c om 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); JPADomainExporter exporter = new JPADomainExporter("Q", new File("target/jpagen2"), convert(config)); exporter.execute();//from w w w .j av a 2 s. c o m 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 @Ignore // FIXME// ww w .j a v a 2 s . co m 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/querydsl/jpa/domain3/QStore.java"); assertContains(targetFile, "StringPath code", "StringPath address"); targetFile = new File("target/jpagen5/com/querydsl/jpa/domain3/QHardwareStore.java"); assertContains(targetFile, "StringPath code = _super.code;", "StringPath address"); }
From source file:org.codehaus.mojo.appfuse.mojo.PojoMojoBase.java
License:Apache License
/** * This method will run the database conversion to hbm file mojo task. * // ww w .j a v a 2 s . co m * @throws MojoExecutionException * Thrown if we fail to obtain an appfuse resource. */ public void execute() throws MojoExecutionException { if (getLog().isInfoEnabled()) { getLog().info("Running the " + this.getMojoName() + " mojo with properties " + this); } // Get a Hibernate Mapping Exporter POJOExporter exporter = new POJOExporter(); // Allow the class to set, update or delete property settings before they are handed into the exporter. We use // the passed back property set so that the original on remains intact. Properties updatedProperties = null; // Make sure we have a properties object. if (this.getProcessingProperties() == null) { updatedProperties = new Properties(); } else { updatedProperties = this.getProcessingProperties(); } // Allow the mojo to modify the properties validateProperties(updatedProperties); // Set any custom properties that might have been passed in. exporter.setProperties(updatedProperties); // call create to set up the configuration. Configuration configuration = new Configuration(); List files = this.getListOfFilesToProcess(); getLog().info("Processing " + files.size() + " files based on pattern match "); for (int j = 0; j < files.size(); j++) { String fileName = (String) files.get(j); if (getLog().isDebugEnabled()) { getLog().debug("Adding file " + fileName + " to the processing list"); } configuration.addFile(fileName); } // set the configuratino into the exporter exporter.setConfiguration(configuration); // Set the destination directory if ((this.getOutputDirectory() != null) && (getOutputDirectory().length() > 0)) { exporter.setOutputDirectory(new File(getOutputDirectory())); } else { throw new MojoExecutionException("output directory cannot be null or empty"); } // Set the file pattern model for the ouput files exporter.setFilePattern(getOutputPattern()); // Set the template information. exporter.setTemplateName(getTemplateName()); // run the exporter. exporter.start(); }
From source file:org.jboss.tools.hibernate3_6.ConfigurationFactory.java
License:Open Source License
public Configuration createConfiguration(Configuration localCfg, boolean includeMappings) { Properties properties = prefs.getProperties(); if (properties != null) { // in case the transaction manager is empty then we need to inject a faketm since // hibernate will still try and instantiate it. String str = properties.getProperty(Environment.TRANSACTION_MANAGER_STRATEGY); if (str != null && StringHelper.isEmpty(str)) { properties.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, FAKE_TM_LOOKUP); // properties.setProperty( "hibernate.transaction.factory_class", ""); }/*w w w . ja v a 2s . c om*/ } if (localCfg == null) { localCfg = buildConfiguration(properties, includeMappings); } else { // Properties origProperties = cfg.getProperties(); // origProperties.putAll(properties); // cfg.setProperties(origProperties); // TODO: this is actually only for jdbc reveng... // localCfg = configureStandardConfiguration( includeMappings, localCfg, properties ); } // here both setProperties and configxml have had their chance to tell which databasedriver // is needed. registerFakeDriver(localCfg.getProperty(Environment.DRIVER)); // autoConfigureDialect(localCfg); Disabled for now since it causes very looong timeouts for // non-running databases + i havent been needed until now... // TODO: jpa configuration ? if (includeMappings) { File[] mappingFiles = prefs.getMappingFiles(); for (int i = 0; i < mappingFiles.length; i++) { File hbm = mappingFiles[i]; localCfg = localCfg.addFile(hbm); } } // TODO: HBX- localCfg.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false"); //$NON-NLS-1$//$NON-NLS-2$ localCfg.setProperty(Environment.HBM2DDL_AUTO, "false"); //$NON-NLS-1$ // to fix: JBIDE-5839 & JBIDE-5997 - setup this property: false is default value // to make hibernate tools diff hibernate versions compatible: // if the property not set get NoSuchMethodError with FullTextIndexEventListener if (localCfg.getProperty("hibernate.search.autoregister_listeners") == null) { //$NON-NLS-1$ localCfg.setProperty("hibernate.search.autoregister_listeners", "false"); //$NON-NLS-1$ //$NON-NLS-2$ } return localCfg; }
From source file:org.joda.time.contrib.hibernate.TestPersistentDateTime.java
License:Apache License
protected void setupConfiguration(Configuration cfg) { cfg.addFile(new File("src/test/java/org/joda/time/contrib/hibernate/event.hbm.xml")); cfg.addFile(new File("src/test/java/org/joda/time/contrib/hibernate/eventTZ.hbm.xml")); }
From source file:org.joda.time.contrib.hibernate.TestPersistentDateTimeAsBigInt.java
License:Apache License
protected void setupConfiguration(Configuration cfg) { cfg.addFile(new File("src/test/java/org/joda/time/contrib/hibernate/thingWithDateTimeAsBigInt.hbm.xml")); }
From source file:org.joda.time.contrib.hibernate.TestPersistentDuration.java
License:Apache License
protected void setupConfiguration(Configuration cfg) { cfg.addFile(new File("src/test/java/org/joda/time/contrib/hibernate/testmodel/SomethingThatLasts.hbm.xml")); }
From source file:org.joda.time.contrib.hibernate.TestPersistentDurationAsMilliseconds.java
License:Apache License
protected void setupConfiguration(Configuration cfg) { cfg.addFile(new File( "src/test/java/org/joda/time/contrib/hibernate/testmodel/SomethingThatLastsInMilliseconds.hbm.xml")); }