hbn 笔记


1.Criteria 的 or 

     public  List getFind(String[] dpids ) {
        Criteria cr 
=   getCriteriaBegin(Deptid. class );
        
        cr.add( Restrictions.or( 
                    Restrictions.eq(
" dpid " , dpids[ 0 ] ) , 
                    Restrictions.eq( 
" dpid "  ,dpids[ 1 ] ) )
                );
        
        
return  getCriteriaEnd(cr);
    }

2. 容器储存 (从表没主键) 1)Set  的 .xml
             引用  http://caterpillar.onlyfun.net/GossipCN/HibernateGossip/HibernateGossip.html
	<set name="emails" table="email">//email表 就 2列 id address
<key column="id"/> //email表的主键 也是主表的主键
  <element type="java.lang.String" column="address"/>
</set>
.java private Set emails; //存和外键同
2)List  的 .xml
<list name="items" table="item">
<key column="id"/> //为item表的 idINT(11) NOT NULL,
<index column="position"/> //为表的 position INT(11) NOT NULL,
<element type="java.lang.String" column="name"/>//为表的name VARCHAR(100) NOT NULL default ''
</list>
。。。。。
3. 列为对象
<set name="emails" table="email">
<key column="id"/>
<composite-element class="onlyfun.caterpillar.MailAddress">
<property name="address" column="address"/> //调用 getAddress()
</composite-element>
</set>


你可能感兴趣的:(hbn 笔记)