- public HibernateComponent(String aName) throws IOException {
- super(aName, new String[] { HIBERNATE_SPRING_CONFIG},
- createProvided(), createRequired());
-
- Properties props = new Properties();
- props.load(new ClassPathResource(HIBERNATE_PROPERTIES).getInputStream());
- addProperties(props);
+ Properties props = new Properties();
+ addProperties(HIBERNATE_PROPS_KEY, props);
+
+ addRequiredInterface(config);
+ }
+
+ @Override
+ protected Scope doStart(Scope aExternalScope) {
+ ORMappingConfig orMappingConfig = aExternalScope.getInterfaceImplementation(
+ config.getProvider(), ORMappingConfig.class);
+ setProperty(HIBERNATE_SCHEMAUPDATE_PROP, "" + orMappingConfig.isSchemaUpdate());
+
+ DatabaseType db = orMappingConfig.getType();
+ String dialect = db.handleCases(new DatabaseType.Switch<String>() {
+ @Override
+ public String handleMySqlInnoDb() {
+ return MySQLInnoDBDialect.class.getName();
+ }
+
+ @Override
+ public String handleDerby() {
+ return DerbyDialect.class.getName();
+ }
+ });
+
+ getHibernateProperties().put(HIBERNATE_DIALECT_PROP, dialect);
+
+ return super.doStart(aExternalScope);
+ }
+
+ private Properties getHibernateProperties() {
+ return getProperties(HIBERNATE_PROPS_KEY);