表字段和实体属性映射命名策略 博客分类: JPAHibernate
hibernate:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">classpath*:/ehcache/ehcache-hibernate-local.xml</prop>
</props>
</property>
<property name="packagesToScan" value="com.lakala.manage.bean,com.lakala.manage.bean.*" />
</bean>
JPA:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="myJPA" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<!--配置Hibernate方言 -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
<!--配置数据库驱动 -->
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<!--配置数据库用户名 -->
<property name="hibernate.connection.username" value=""/>
<!--配置数据库密码 -->
<property name="hibernate.connection.password" value=""/>
<!--配置数据库url -->
<property name="hibernate.connection.url" value=""/>
<!--设置外连接抓取树的最大深度 -->
<property name="hibernate.max_fetch_depth" value="3"/>
<!--自动输出schema创建DDL语句 -->
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="javax.persistence.validation.mode" value="none"/>
<!-- jpa 特有命名策略配置 -->
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
</properties>
</persistence-unit>
</persistence>