下面列出了org.hibernate.cfg.Configuration#getProperties ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public boolean equals(Configuration configuration) {
Properties prop = configuration.getProperties();
if (!driverClass.equals(prop.getProperty(AvailableSettings.DRIVER))) {
return false;
}
if (!dialect.equals(prop.getProperty(AvailableSettings.DIALECT))) {
return false;
}
if (!preferredTestQuery.equals(prop.getProperty(PREFFERED_TEST_QUERY))) {
return false;
}
if (!userName.equals(prop.getProperty(AvailableSettings.USER))) {
return false;
}
if (!password.equals(prop.getProperty(AvailableSettings.PASS))) {
return false;
}
if (!createProtocolUrl(this).equals(prop.getProperty(AvailableSettings.URL))) {
return false;
}
return true;
}
@Before
public void printBanner() {
final OLATLocalSessionFactoryBean bean = (OLATLocalSessionFactoryBean) CoreSpringFactory.getBean(OLATLocalSessionFactoryBean.class);
final Configuration configuration = bean.getConfiguration();
final Properties properties = configuration.getProperties();
final String[] propsOfInterest = new String[] { "hibernate.connection.driver_class", "hibernate.connection.provider_class", "hibernate.connection.url",
"hibernate.connection.username", };
final String connectionURL = (String) properties.get("hibernate.connection.url");
hsqlDBConfigured = connectionURL != null && connectionURL.toLowerCase().indexOf("hsqldb") > 0;
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
for (int i = 0; i < propsOfInterest.length; i++) {
System.out.println("++" + propsOfInterest[i] + " -> " + properties.getProperty(propsOfInterest[i]));
}
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
printOlatLocalProperties();
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println("+ OLAT configuration initialized, starting now with junit tests +");
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
}
@Before
public void printBanner() {
final OLATLocalSessionFactoryBean bean = (OLATLocalSessionFactoryBean) CoreSpringFactory.getBean(OLATLocalSessionFactoryBean.class);
final Configuration configuration = bean.getConfiguration();
final Properties properties = configuration.getProperties();
final String[] propsOfInterest = new String[] { "hibernate.connection.driver_class", "hibernate.connection.provider_class", "hibernate.connection.url",
"hibernate.connection.username", };
final String connectionURL = (String) properties.get("hibernate.connection.url");
hsqlDBConfigured = connectionURL != null && connectionURL.toLowerCase().indexOf("hsqldb") > 0;
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
for (int i = 0; i < propsOfInterest.length; i++) {
System.out.println("++" + propsOfInterest[i] + " -> " + properties.getProperty(propsOfInterest[i]));
}
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
printOlatLocalProperties();
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println("+ OLAT configuration initialized, starting now with junit tests +");
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
}
public void applyConfig(Configuration configuration) {
Properties prop = configuration.getProperties();
try {
String url = prop.getProperty(AvailableSettings.URL, "");
URI full = new URI(url);
URI uri = new URI(full.getSchemeSpecificPart());
setProtocol(full.getScheme());
setSubProtocol(uri.getScheme());
setHost(uri.getHost());
int intPort = uri.getPort();
port = intPort == -1 ? "" : String.valueOf(intPort);
path = uri.getPath().replace("/", "");
query = uri.getQuery();
} catch (URISyntaxException e) {
logger.error("Could not parse hibernate url.", e);
}
driverClass = prop.getProperty(AvailableSettings.DRIVER);
dialect = prop.getProperty(AvailableSettings.DIALECT);
preferredTestQuery = prop.getProperty(PREFFERED_TEST_QUERY, "SELECT 1;");
userName = prop.getProperty(AvailableSettings.USER, "sailfish");
password = prop.getProperty(AvailableSettings.PASS, "999");
}
public SchemaUpdate(Configuration cfg) throws HibernateException {
this(cfg, cfg.getProperties());
}
/**
* Create a schema exporter for the given Configuration
*/
public SchemaExport(Configuration cfg) throws HibernateException {
this( cfg, cfg.getProperties() );
}
public SchemaUpdate(Configuration cfg) throws HibernateException {
this( cfg, cfg.getProperties() );
}
public SchemaValidator(Configuration cfg) throws HibernateException {
this( cfg, cfg.getProperties() );
}