在 applicationContent.xml 文件中加入以下程序代码,及可以Console中看到 hibernate 执行sql 语句
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/pecope">
</property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">false</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.zbb.entity.Salesman</value>
<value>com.zbb.entity.Plan</value>
<value>com.zbb.entity.Schedule</value>
<value>com.zbb.entity.Room</value>
<value>com.zbb.entity.Customer</value>
<value>com.zbb.entity.Message</value>
<value>com.zbb.entity.Material</value>
<value>com.zbb.entity.Project</value>
<value>com.zbb.entity.Bargain</value>
<value>com.zbb.entity.Plan2</value>
</list>
</property>
</bean>
<property name="driverClassName" value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/pecope">
</property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">false</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.zbb.entity.Salesman</value>
<value>com.zbb.entity.Plan</value>
<value>com.zbb.entity.Schedule</value>
<value>com.zbb.entity.Room</value>
<value>com.zbb.entity.Customer</value>
<value>com.zbb.entity.Message</value>
<value>com.zbb.entity.Material</value>
<value>com.zbb.entity.Project</value>
<value>com.zbb.entity.Bargain</value>
<value>com.zbb.entity.Plan2</value>
</list>
</property>
</bean>