Java Code Examples for org.hibernate.cfg.Configuration#addJar()
The following examples show how to use
org.hibernate.cfg.Configuration#addJar() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HibernateDataSource.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
protected void addDatamart(FileDataSourceConfiguration configuration, boolean extendClassLoader) { Configuration cfg = null; SessionFactory sf = null; if(configuration.getFile() == null) return; cfg = buildEmptyConfiguration(); configurationMap.put(configuration.getModelName(), cfg); if (extendClassLoader){ updateCurrentClassLoader(configuration.getFile()); } cfg.addJar(configuration.getFile()); try { compositeHibernateConfiguration.addJar(configuration.getFile()); } catch (Throwable t) { throw new RuntimeException("Cannot add datamart", t); } sf = cfg.buildSessionFactory(); sessionFactoryMap.put(configuration.getModelName(), sf); }
Example 2
Source File: HibernateDataSourceWithClassLoader.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void addDatamart(FileDataSourceConfiguration configuration, boolean extendClassLoader) { Configuration cfg = null; SessionFactory sf = null; if(configuration.getFile() == null) return; cfg = buildEmptyConfiguration(); configurationMap.put(configuration.getModelName(), cfg); if (extendClassLoader){ myClassLoader = ClassLoaderManager.updateCurrentClassLoader(configuration.getFile()); } cfg.addJar(configuration.getFile()); try { compositeHibernateConfiguration.addJar(configuration.getFile()); } catch (Throwable t) { throw new RuntimeException("Cannot add datamart", t); } sf = cfg.buildSessionFactory(); sessionFactoryMap.put(configuration.getModelName(), sf); }
Example 3
Source File: SchemaExportTask.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
private Configuration getConfiguration() throws Exception { Configuration cfg = new Configuration(); if (namingStrategy!=null) { cfg.setNamingStrategy( (NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance() ); } if (configurationFile != null) { cfg.configure( configurationFile ); } String[] files = getFiles(); for (int i = 0; i < files.length; i++) { String filename = files[i]; if ( filename.endsWith(".jar") ) { cfg.addJar( new File(filename) ); } else { cfg.addFile(filename); } } return cfg; }
Example 4
Source File: SchemaUpdateTask.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
private Configuration getConfiguration() throws Exception { Configuration cfg = new Configuration(); if (namingStrategy!=null) { cfg.setNamingStrategy( (NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance() ); } if (configurationFile!=null) { cfg.configure( configurationFile ); } String[] files = getFiles(); for (int i = 0; i < files.length; i++) { String filename = files[i]; if ( filename.endsWith(".jar") ) { cfg.addJar( new File(filename) ); } else { cfg.addFile(filename); } } return cfg; }
Example 5
Source File: SchemaValidatorTask.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
private Configuration getConfiguration() throws Exception { Configuration cfg = new Configuration(); if (namingStrategy!=null) { cfg.setNamingStrategy( (NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance() ); } if (configurationFile!=null) { cfg.configure( configurationFile ); } String[] files = getFiles(); for (int i = 0; i < files.length; i++) { String filename = files[i]; if ( filename.endsWith(".jar") ) { cfg.addJar( new File(filename) ); } else { cfg.addFile(filename); } } return cfg; }
Example 6
Source File: SchemaExport.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public static void main(String[] args) { try { Configuration cfg = new Configuration(); boolean script = true; boolean drop = false; boolean create = false; boolean halt = false; boolean export = true; String outFile = null; String importFile = "/import.sql"; String propFile = null; boolean format = false; String delim = null; for ( int i = 0; i < args.length; i++ ) { if ( args[i].startsWith( "--" ) ) { if ( args[i].equals( "--quiet" ) ) { script = false; } else if ( args[i].equals( "--drop" ) ) { drop = true; } else if ( args[i].equals( "--create" ) ) { create = true; } else if ( args[i].equals( "--haltonerror" ) ) { halt = true; } else if ( args[i].equals( "--text" ) ) { export = false; } else if ( args[i].startsWith( "--output=" ) ) { outFile = args[i].substring( 9 ); } else if ( args[i].startsWith( "--import=" ) ) { importFile = args[i].substring( 9 ); } else if ( args[i].startsWith( "--properties=" ) ) { propFile = args[i].substring( 13 ); } else if ( args[i].equals( "--format" ) ) { format = true; } else if ( args[i].startsWith( "--delimiter=" ) ) { delim = args[i].substring( 12 ); } else if ( args[i].startsWith( "--config=" ) ) { cfg.configure( args[i].substring( 9 ) ); } else if ( args[i].startsWith( "--naming=" ) ) { cfg.setNamingStrategy( ( NamingStrategy ) ReflectHelper.classForName( args[i].substring( 9 ) ) .newInstance() ); } } else { String filename = args[i]; if ( filename.endsWith( ".jar" ) ) { cfg.addJar( new File( filename ) ); } else { cfg.addFile( filename ); } } } if ( propFile != null ) { Properties props = new Properties(); props.putAll( cfg.getProperties() ); props.load( new FileInputStream( propFile ) ); cfg.setProperties( props ); } SchemaExport se = new SchemaExport( cfg ) .setHaltOnError( halt ) .setOutputFile( outFile ) .setImportFile( importFile ) .setDelimiter( delim ); if ( format ) { se.setFormat( true ); } se.execute( script, export, drop, create ); } catch ( Exception e ) { log.error( "Error creating schema ", e ); e.printStackTrace(); } }