Reputation: 16541
using this in my hibernate cfg:
<property name="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</property>
<property name="hibernate.hbm2ddl.auto">create</property>
This should make all my tables and column snake_case
in database.
But it is just making them camelCase
.
What could be the problem?
private String myName;
in my database it is still myName(varchar(255))
Upvotes: 2
Views: 6004
Reputation: 754
@Jaanus was too hasty in rejecting the links provided by @Renjith
The link states that it does work in XML but has to be injected as a property of the session factory as shown in the XML code extract below:
<!-- object to relational mapping configuration -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="hibernateProperties">
<property name="map">
<map>
<entry key="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<entry key="hibernate.hbm2ddl.auto" value="validate" />
<entry key="hibernate.connection.charSet" value="UTF-8" />
<entry key="hibernate.show_sql" value="true" />
<entry key="hibernate.jdbc.batch_size" value="0" />
</map>
</property>
</property>
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="dataSource" ref="dataSource" />
...
</bean>
Upvotes: 4
Reputation: 16541
Setting hibernate.ejb.naming_strategy
programmatically worked.
configuration.setNamingStrategy(ImprovedNamingStrategy.INSTANCE);
Still wondering why it didn't work from XML, should work.
Upvotes: 4