本文整理汇总了Java中org.hibernate.cfg.Configuration.addFile方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.addFile方法的具体用法?Java Configuration.addFile怎么用?Java Configuration.addFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.addFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConfiguration
import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
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;
}
示例2: getConfiguration
import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
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;
}
示例3: getConfiguration
import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
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;
}
示例4: main
import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
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 );
}
StandardServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
try {
new SchemaUpdate( serviceRegistry, cfg ).execute( script, doUpdate );
}
finally {
serviceRegistry.destroy();
}
}
catch ( Exception e ) {
LOG.unableToRunSchemaUpdate(e);
e.printStackTrace();
}
}
示例5: main
import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
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 );
}
StandardServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
try {
new SchemaValidator( serviceRegistry, cfg ).validate();
}
finally {
serviceRegistry.destroy();
}
}
catch ( Exception e ) {
LOG.unableToRunSchemaUpdate(e);
e.printStackTrace();
}
}