摘要:
閱讀全文
posted @
2017-09-04 16:33 David1228 閱讀(313) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2017-08-02 11:41 David1228 閱讀(335) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2017-07-24 19:10 David1228 閱讀(11409) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2017-07-19 18:10 David1228 閱讀(3446) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2017-06-06 23:10 David1228 閱讀(298) |
評論 (0) |
編輯 收藏
posted @
2017-06-06 23:09 David1228 閱讀(250) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2017-05-30 19:26 David1228 閱讀(3298) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2017-05-30 19:25 David1228 閱讀(1266) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2016-12-22 23:01 David1228 閱讀(4628) |
評論 (2) |
編輯 收藏
摘要:
閱讀全文
posted @
2016-11-04 23:44 David1228 閱讀(2310) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2016-07-28 17:57 David1228 閱讀(406) |
評論 (0) |
編輯 收藏
摘要: JVM調(diào)優(yōu)總結(jié) + jstat 分析jstat -gccause pid 1 每格1毫秒輸出結(jié)果jstat -gccause pid 2000 每格2秒輸出結(jié)果不斷的在屏幕打印出結(jié)果 S0 S1 E &n...
閱讀全文
posted @
2016-01-03 23:26 David1228 閱讀(3005) |
評論 (2) |
編輯 收藏
摘要:
閱讀全文
posted @
2015-12-27 16:49 David1228 閱讀(1099) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2015-10-31 12:37 David1228 閱讀(677) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2015-10-30 20:20 David1228 閱讀(2891) |
評論 (0) |
編輯 收藏
轉(zhuǎn)載文章:
http://www.qixing318.com/article/by-lua-adhesive-nginx-ecological-environment.html
posted @
2015-09-08 13:22 David1228 閱讀(520) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2015-09-08 09:34 David1228|
編輯 收藏
摘要:
閱讀全文
posted @
2015-07-29 13:48 David1228 閱讀(5563) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2014-12-03 23:56 David1228 閱讀(28352) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2013-11-19 11:48 David1228 閱讀(23759) |
評論 (1) |
編輯 收藏
摘要:
閱讀全文
posted @
2013-11-18 18:01 David1228 閱讀(2912) |
評論 (4) |
編輯 收藏
摘要:
閱讀全文
posted @
2013-10-31 17:32 David1228 閱讀(713) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2013-10-14 09:50 David1228 閱讀(21772) |
評論 (6) |
編輯 收藏
Hibernate不支持left join帶on的條件查詢。
解決辦法:使用原生SQL或者使用HQL方式需要修改hbm文件(如果項目中大部分不適用級聯(lián)配置情況下)
需求是查詢網(wǎng)絡(luò)信息,網(wǎng)絡(luò)信息中關(guān)聯(lián)了分區(qū)、網(wǎng)絡(luò)IP(1個網(wǎng)絡(luò)--N個網(wǎng)絡(luò)IP),網(wǎng)橋信息.
HQL:
public void queryVnets(Page page) {
StringBuffer hql = new StringBuffer();
hql.append("select new Map(vn.id as id, vn.vnName as vnName, b.name as vnType, ");
hql.append("vn.vnIptype as vnIptype, vn.vnIp as vnIp,vn.vnNat as vnNat, vn.vnFlag as vnFlag, ");
hql.append("vn.vnetFlag as vnetFlag, (case when sum(vmvn.state)='0' then 0 else 1 end) as vnState, ");
hql.append("vn.useType as useType, vn.createTime as createTime, ");
hql .append("zone.oneName as oneName, zone.oneHypervisor as oneHypervisor, zone.oneSeq as oneSeq) ");
hql.append("from VnetTable vn, ZoneTable zone, BridgeTable b ");
hql.append("left join fetch vn.VnTables vmvn where zone.id = vn.zoneId and vn.vnType = b.id ");
... ...
hql.append(" group by vn.id");
if (vnState != null && !"".equals(vnState)) {
if ("0".equals(vnState)) {
hql.append(" having sum(vmvn.state)=0");
} else if ("1".equals(vnState)) {
hql.append(" having sum(vmvn.state)!=0");
}
}
}
hbm配置文件:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.base.mapping.VnetTable" table="vnet_table" >
<id name="id" type="java.lang.String">
<column name="ID" length="32" />
<generator class="uuid.hex" />
</id>
<property name="vnId" type="java.lang.Long">
<column name="VN_ID">
<comment>創(chuàng)建虛擬網(wǎng)絡(luò)時得到的ID</comment>
</column>
</property>
...
<property name="zoneId" type="java.lang.String">
<column name="ZONE_ID" length="32">
<comment>分區(qū)ID</comment>
</column>
</property>
<property name="vlanId" type="java.lang.Integer">
<column name="VLAN_ID">
<comment>VLAN_ID</comment>
</column>
</property>
<set name="vnTables" lazy="false" order-by="id asc" inverse="false" fetch="join" cascade="all">
<key column="VN_NID"/>
<one-to-many class="com.base.mapping.VnTable"/>
</set>
</class>
</hibernate-mapping>
理解inverse和cascade,可以參考:http://blog.csdn.net/wkcgy/article/details/6271321
總結(jié): <one-to-many>中,建議inverse=”true”,由“many”方來進(jìn)行關(guān)聯(lián)關(guān)系的維護(hù) <many-to-many>中,只設(shè)置其中一方inverse=”false”,或雙方都不設(shè)置 Cascade,通常情況下都不會使用。特別是刪除,一定要慎重。操作建議
一般對many-to-one和many-to-many不設(shè)置級聯(lián),這要看業(yè)務(wù)邏輯的需要;對one-to-one和one-to-many設(shè)置級聯(lián)。 many-to-many關(guān)聯(lián)關(guān)系中,一端設(shè)置inverse=”false”,另一端設(shè)置為inverse=”true”。在one-to-many關(guān)聯(lián)關(guān)系中,設(shè)置inverse=”true”,由多端來維護(hù)關(guān)系表
posted @
2013-09-12 11:57 David1228 閱讀(16703) |
評論 (2) |
編輯 收藏