本文整理匯總了Java中org.hibernate.cfg.Configuration.setProperties方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.setProperties方法的具體用法?Java Configuration.setProperties怎麽用?Java Configuration.setProperties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.setProperties方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSchemaUpdate
import org.hibernate.cfg.Configuration; //導入方法依賴的package包/類
private SchemaUpdate getSchemaUpdate(Configuration cfg) throws HibernateException, IOException {
Properties properties = new Properties();
properties.putAll( cfg.getProperties() );
if (propertiesFile == null) {
properties.putAll( getProject().getProperties() );
}
else {
properties.load( new FileInputStream(propertiesFile) );
}
cfg.setProperties(properties);
SchemaUpdate su = new SchemaUpdate(cfg);
su.setOutputFile( outputFile.getPath() );
su.setDelimiter(delimiter);
su.setHaltOnError(haltOnError);
return su;
}
示例2: getSchemaExport
import org.hibernate.cfg.Configuration; //導入方法依賴的package包/類
private SchemaExport getSchemaExport(Configuration cfg) throws HibernateException, IOException {
Properties properties = new Properties();
properties.putAll( cfg.getProperties() );
if (propertiesFile == null) {
properties.putAll( getProject().getProperties() );
}
else {
properties.load( new FileInputStream(propertiesFile) );
}
cfg.setProperties(properties);
return new SchemaExport(cfg)
.setHaltOnError(haltOnError)
.setOutputFile( outputFile.getPath() )
.setDelimiter(delimiter);
}
示例3: getSchemaValidator
import org.hibernate.cfg.Configuration; //導入方法依賴的package包/類
private SchemaValidator getSchemaValidator(Configuration cfg) throws HibernateException, IOException {
Properties properties = new Properties();
properties.putAll( cfg.getProperties() );
if (propertiesFile == null) {
properties.putAll( getProject().getProperties() );
}
else {
properties.load( new FileInputStream(propertiesFile) );
}
cfg.setProperties(properties);
return new SchemaValidator(cfg);
}
示例4: newSessionFactory
import org.hibernate.cfg.Configuration; //導入方法依賴的package包/類
private SessionFactory newSessionFactory() {
Properties properties = properties();
Configuration configuration = new Configuration().addProperties(properties);
for (Class<?> entityClass : entities()) {
configuration.addAnnotatedClass(entityClass);
}
String[] packages = packages();
if (packages != null) {
for (String scannedPackage : packages) {
configuration.addPackage(scannedPackage);
}
}
String[] resources = resources();
if (resources != null) {
for (String resource : resources) {
configuration.addResource(resource);
}
}
Interceptor interceptor = interceptor();
if (interceptor != null) {
configuration.setInterceptor(interceptor);
}
configuration.setProperties(properties);
return configuration.buildSessionFactory(
new BootstrapServiceRegistryBuilder()
.build()
);
}
示例5: 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();
}
}
示例6: 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();
}
}