Created
February 23, 2012 15:06
-
-
Save rponte/1893210 to your computer and use it in GitHub Desktop.
configuring Hibernate (JPA) ImprovedNamingStrategy which prefers embedded underscores to mixed case names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="entityManagerFactory" | |
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> | |
<property name="dataSource" ref="dataSource"/> | |
<property name="jpaVendorAdapter"> | |
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> | |
<property name="showSql" value="true" /> | |
<property name="databasePlatform" value="${hibernate.databasePlatform}" /> | |
</bean> | |
</property> | |
<property name="jpaProperties"> | |
<props> | |
<prop key="hibernate.format_sql">true</prop> | |
<prop key="hibernate.hbm2ddl.auto">create-drop</prop> <!-- create | create-drop | validate | update --> | |
<prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop> | |
</props> | |
</property> | |
</bean> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is the behavior of the org.hibernate.cfg.ImprovedNamingStrategy , which will convert the mixed case names to the embedded underscores name . http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/cfg/ImprovedNamingStrategy.html . So if you explicitly use the name "EventLog" , it will convert to the "event_log" .
If you simply want to use the name explicitly specified in the @table , you should use the org.hibernate.cfg.DefaultNamingStrategy . By default it is used when you instantiate your org.hibernate.cfg.Configuration object
more informations,
http://stackoverflow.com/questions/5050538/hibernate-improvednamingstrategy-overrides-table-name-in-entity