org.hibernate.cfg.NamingStrategy Java Examples
The following examples show how to use
org.hibernate.cfg.NamingStrategy.
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: LocalSessionFactoryBeanTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("serial") public void testLocalSessionFactoryBeanWithNamingStrategy() throws Exception { LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() { @Override protected Configuration newConfiguration() { return new Configuration() { @Override public Configuration setNamingStrategy(NamingStrategy namingStrategy) { throw new IllegalArgumentException(namingStrategy.toString()); } }; } }; sfb.setMappingResources(new String[0]); sfb.setDataSource(new DriverManagerDataSource()); sfb.setNamingStrategy(ImprovedNamingStrategy.INSTANCE); try { sfb.afterPropertiesSet(); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException ex) { // expected assertTrue("Correct exception", ex.getMessage().equals(ImprovedNamingStrategy.INSTANCE.toString())); } }
Example #2
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 #3
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 #4
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 #5
Source File: SchemaValidator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void main(String[] args) { try { Configuration cfg = new Configuration(); String propFile = null; for ( int i = 0; i < args.length; i++ ) { if ( args[i].startsWith( "--" ) ) { if ( args[i].startsWith( "--properties=" ) ) { propFile = args[i].substring( 13 ); } 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 { cfg.addFile( args[i] ); } } if ( propFile != null ) { Properties props = new Properties(); props.putAll( cfg.getProperties() ); props.load( new FileInputStream( propFile ) ); cfg.setProperties( props ); } new SchemaValidator( cfg ).validate(); } catch ( Exception e ) { log.error( "Error running schema update", e ); e.printStackTrace(); } }
Example #6
Source File: SchemaUpdate.java From document-management-system with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { try { Configuration cfg = new Configuration(); String outFile = null; boolean script = true; // If true then execute db updates, otherwise just generate and // display updates boolean doUpdate = true; String propFile = null; for (int i = 0; i < args.length; i++) { if (args[i].startsWith("--")) { if (args[i].equals("--quiet")) { script = false; } else if (args[i].startsWith("--properties=")) { propFile = args[i].substring(13); } else if (args[i].startsWith("--config=")) { cfg.configure(args[i].substring(9)); } else if (args[i].startsWith("--text")) { doUpdate = false; } else if (args[i].startsWith("--naming=")) { cfg.setNamingStrategy((NamingStrategy) ReflectHelper.classForName( args[i].substring(9)).newInstance()); } else if (args[i].startsWith("--output=")) { outFile = args[i].substring(9); } } else { cfg.addFile(args[i]); } } if (propFile != null) { Properties props = new Properties(); props.putAll(cfg.getProperties()); props.load(new FileInputStream(propFile)); cfg.setProperties(props); } new SchemaUpdate(cfg).setOutputFile(outFile).execute(script, doUpdate); } catch (Exception e) { log.error("Error running schema update", e); e.printStackTrace(); } }
Example #7
Source File: HibernateMappingContextSessionFactoryBean.java From gorm-hibernate5 with Apache License 2.0 | 4 votes |
public NamingStrategy getNamingStrategy() { return namingStrategy; }
Example #8
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(); } }
Example #9
Source File: SchemaUpdate.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; // If true then execute db updates, otherwise just generate and display updates boolean doUpdate = true; String propFile = null; for ( int i = 0; i < args.length; i++ ) { if ( args[i].startsWith( "--" ) ) { if ( args[i].equals( "--quiet" ) ) { script = false; } else if ( args[i].startsWith( "--properties=" ) ) { propFile = args[i].substring( 13 ); } else if ( args[i].startsWith( "--config=" ) ) { cfg.configure( args[i].substring( 9 ) ); } else if ( args[i].startsWith( "--text" ) ) { doUpdate = false; } else if ( args[i].startsWith( "--naming=" ) ) { cfg.setNamingStrategy( ( NamingStrategy ) ReflectHelper.classForName( args[i].substring( 9 ) ).newInstance() ); } } else { cfg.addFile( args[i] ); } } if ( propFile != null ) { Properties props = new Properties(); props.putAll( cfg.getProperties() ); props.load( new FileInputStream( propFile ) ); cfg.setProperties( props ); } new SchemaUpdate( cfg ).execute( script, doUpdate ); } catch ( Exception e ) { log.error( "Error running schema update", e ); e.printStackTrace(); } }
Example #10
Source File: LocalSessionFactoryBean.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Set a Hibernate NamingStrategy for the SessionFactory, determining the * physical column and table names given the info in the mapping document. * @see org.hibernate.cfg.Configuration#setNamingStrategy */ public void setNamingStrategy(NamingStrategy namingStrategy) { this.namingStrategy = namingStrategy; }
Example #11
Source File: LocalSessionFactoryBean.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Set a Hibernate NamingStrategy for the SessionFactory, determining the * physical column and table names given the info in the mapping document. * @see org.hibernate.cfg.Configuration#setNamingStrategy */ public void setNamingStrategy(NamingStrategy namingStrategy) { this.namingStrategy = namingStrategy; }
Example #12
Source File: HibernateMappingContextSessionFactoryBean.java From gorm-hibernate5 with Apache License 2.0 | 2 votes |
/** * Set a Hibernate NamingStrategy for the SessionFactory, determining the * physical column and table names given the info in the mapping document. */ public void setNamingStrategy(NamingStrategy namingStrategy) { this.namingStrategy = namingStrategy; }