我使用Hibernate和Spring
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" destroy-method="close">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>Entity/Familyperson.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
貌似和
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
有区别(两种的data一样)
声明式事物管理,<aop:pointcut id="allManagerMethod" expression="execution(* Entity11.*.*(..))"/>
没这个Entity11包;
我用一个sava(Object)方法,用上面一种配置可以存数据。
用下面一种方法,不能存储数据(跟我想的一样,因为事物没有添加进去)
我猜想是不是hibernate.cfg.xml有什么默认值。
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" destroy-method="close">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>Entity/Familyperson.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
貌似和
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
有区别(两种的data一样)
声明式事物管理,<aop:pointcut id="allManagerMethod" expression="execution(* Entity11.*.*(..))"/>
没这个Entity11包;
我用一个sava(Object)方法,用上面一种配置可以存数据。
用下面一种方法,不能存储数据(跟我想的一样,因为事物没有添加进去)
我猜想是不是hibernate.cfg.xml有什么默认值。
个人认为两种方式没什么区别,只是把hibernate的配置放在不同文件而已