java - Hibernate Naming Strategy is ignored -
i configured hibernate in application through persistence.xml looks like:
<persistence-unit name="entitymanager" transaction-type="resource_local"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <properties> <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.improvednamingstrategy" /> <property name="hibernate.archive.autodetection" value="class" /> <property name="hibernate.hbm2ddl.auto" value="update" /> </properties> </persistence-unit>
and through entitymanagerutil class create enitymanagerfactory:
config config=commonsettings.getinstance().config; map<string, object> configoverrides = new hashmap<string, object>(); configoverrides.put("hibernate.ejb.naming_strategy","org.hibernate.cfg.improvednamingstrategy"); configoverrides.put("hibernate.dialect",config.hibernateconfig.dialect); configoverrides.put("hibernate.show_sql", config.hibernateconfig.showsql); configoverrides.put("hibernate.max_fetch_depth", config.hibernateconfig.maxfetchdepth); configoverrides.put("hibernate.jdbc.batch_size",config.hibernateconfig.batchsize); configoverrides.put("hibernate.connection.pool_size", config.hibernateconfig.poolsize); configoverrides.put("hibernate.connection.charset", config.hibernateconfig.charset); configoverrides.put("hibernate.connection.characterencoding",config.hibernateconfig.characterencoding); configoverrides.put("hibernate.connection.useunicode", config.hibernateconfig.useunicode); configoverrides.put("hibernate.connection.autocommit", config.hibernateconfig.autocommit); configoverrides.put("hibernate.connection.release_mode",config.hibernateconfig.releasemode); configoverrides.put("hibernate.cache.use_second_level_cache", config.hibernateconfig.usesecondlevelcache); configoverrides.put("hibernate.cache.use_query_cache", config.hibernateconfig.usequerycache); configoverrides.put("hibernate.cache.use_structured_entries", config.hibernateconfig.usestructuredentries); configoverrides.put("hibernate.cache.region.factory_class",config.hibernateconfig.factoryclass); configoverrides.put("packagestoscan", "org.prosolo.common.domainmodel"); configoverrides.put("javax.persistence.jdbc.driver",config.mysqlconfig.jdbcdriver); configoverrides.put("javax.persistence.jdbc.url", "jdbc:mysql://" + host + ":" + port + "/" + database); configoverrides.put("javax.persistence.jdbc.user", user); configoverrides.put("javax.persistence.jdbc.password", password); try{ emf = persistence.createentitymanagerfactory("entitymanager", configoverrides); }catch(exception ex){ ex.printstacktrace(); }
i tried configure naming strategy improvednamingstrategy in persistence.xml , in config overrides. however, doesn't work , hibernate generates new tables camelcase table names.
any idea i'm doing wrong here?
thanks
your mapping looks fine suspect configuration overridden in bootstrap process.
try adding break-point in entitymanagerfactorybuilderimpl.processproperties()
method @ code block:
else if ( availablesettings.naming_strategy.equals( keystring ) ) { namingstrategy = strategyselector.resolvestrategy( namingstrategy.class, entry.getvalue() ); } else if ( availablesettings.naming_strategy_delegator.equals( keystring ) ) { namingstrategydelegator = strategyselector.resolvestrategy( namingstrategydelegator.class, entry.getvalue() ); }
and see if configuration available there.
Comments
Post a Comment