一、概述spring
二、實體對象的生命週期sql
三、VO與 PO數據庫
四、session接口數組
session管理方案:session
第二種方法:數據結構
<?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" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan"> <list> <value>com.isoftstone.persistance.bean</value> <value>com.iss.cloud.portal.modules</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">none</prop> <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop> </props> <!-- <value> hibernate.dialect=org.hibernate.dialect.HSQLDialect hibernate.format_sql=true hibernate.show_sql=true hibernate.hbm2ddl.auto=update<# # spaces here for exception> </value> --> <!-- hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.current_session_context_class=org.hibernate.context.internal.JTASessionContext hibernate.transaction.jta.platform=org.hibernate.service.jta.platform.internal.SunOneJtaPlatform --> </property> <!--<property name="jtaTransactionManager"> <ref bean="transactionManager"/> </property> --> </bean> </beans>
五、session的使用spa
執行save方法時得3種操做:.net
執行save方法後,hibernate
執行commit方法後,3d
1)
2)
六、hibernate的映射類型
來靈活定製客戶化映射類型。瞭解
底層數據庫使用數據類型訪問數據庫,而hibernate使用JDBC驅動訪問數據庫,jdbc驅動程序對底層數據庫使用標準SQL類型進行封裝,向上提供標準SQL類型接口,那麼hibernate就能夠使用標準
SQL類型來生成DML
也能夠定義爲byte[]
或者:
根據此返回值讀取該內容
也能夠是String類型
七、值類型集合的映射方法
結果爲:2
插入時,會把對象插入有序的對象序列,支持兩種排序方式,天然排序和客戶化排序,默認天然排序,當使用天然排序時,
只能向TreeSet中加入相同類型的對象,而且這些對象的類型必須實現了Comparable接口;而客戶化排序必須實現Comparator
接口,此接口定義了compare方法,實現這個方法,定義本身的排序規則,當建立TreeSet對象時,就把咱們對Comparator接口的實現類的實例化對象做爲其初始化參數,調用添加方法時,就會使用客戶化排序規則排序。
建立users表和images表
聯合主鍵:
主要實現類有LinkedList和ArrayList,LinkedList採用鏈表數據結構,ArrayList表明大小可變的數組,List接口還有一個實現類Vector,Vector類的實現採用了同步機制,而ArrayList沒有使用同步機制。
List對集合中的對象按索引位置排序,容許按照對象在集合中的索引位置添加和查找對象,
修改聯合主鍵
無需設置position屬性。
小結: