发表于: 2018-01-14 23:55:49

1 654


今天完成的事情:

时日无多。感觉自己进入瓶颈。

对这个复盘渐渐失去了感情。

需要快速进入状态了。

太长时间没和家里人吃饭了,今天终于一起吃了晚饭,还不错。

自己看了一些关于hibernate的东西。下面贴一点吧:

//配置

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
   <context:annotation-config />
   <context:component-scan base-package="com"/>
   <mvc:annotation-driven/>
   <bean id="propertyConfigurer"
         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
       <property name="location" value="classpath:config.properties" />
   </bean>
   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
         destroy-method="close">
       <property name="driverClassName" value="${jdbc.driver}" />
       <property name="url" value="${jdbc.url}" />
       <property name="username" value="${jdbc.username}" />
       <property name="password" value="${jdbc.password}" />
       <!-- 初始化连接大小 -->
       <property name="initialSize" value="10"/>
       <!-- 连接池最大数量 -->
       <property name="maxActive" value="40"/>
       <!-- 连接池最大空闲 -->
       <property name="maxIdle" value="20"/>
       <!-- 连接池最小空闲 -->
       <property name="minIdle" value="10"/>
   </bean>
   <!--配置session工厂-->
   <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
       <property name="dataSource" ref="dataSource" />
       <property name="packagesToScan" value="com.pojo" />
       <property name="hibernateProperties">
           <props>
               <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <!--hibernate根据实体自动生成数据库表-->
               <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>     <!--在控制台显示执行的数据哭操作语句(格式)-->
           </props>
       </property>
   </bean>
   <!--事务管理配置-->
   <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactory" />
   </bean>
</beans>

hibernate就是把一个对象看作一张表,属性就是表中对应的字段。主要是把配置配正确。



<hibernate-configuration>
   <session-factory>

       <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
       <property name="show_sql">true</property>
       <property name="format_sql">true</property>
       <property name="hbm2ddl.auto">update</property>
       <mapping class="com.pojo.User"/>

       <!-- 配置二级缓存相关 -->

   </session-factory>
</hibernate-configuration>



明天计划的事情:
继续学习SSH框架。学习分页查询吧。设计具体的方案。
遇到的问题:

配置问题。
收获:

对SSH有初步认知。


返回列表 返回列表
评论

    分享到