??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲男人网站,日韩大胆人体,亚洲欧美综合久久久http://www.aygfsteel.com/liuzheng/category/24701.htmlzh-cnFri, 25 Apr 2008 12:45:25 GMTFri, 25 Apr 2008 12:45:25 GMT60Hibernate 的中文参考文?/title><link>http://www.aygfsteel.com/liuzheng/articles/195186.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Wed, 23 Apr 2008 09:42:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/195186.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/195186.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/195186.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/195186.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/195186.html</trackback:ping><description><![CDATA[<p align="right"> </p> http://docs.huihoo.com/framework/hibernate/reference-v3_zh-cn/<br /> Hibernate 的中文参考文? <img src ="http://www.aygfsteel.com/liuzheng/aggbug/195186.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2008-04-23 17:42 <a href="http://www.aygfsteel.com/liuzheng/articles/195186.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Hibernate中关于对复合主键的映和处理http://www.aygfsteel.com/liuzheng/articles/150675.html刘铮 刘铮 Sat, 06 Oct 2007 03:37:00 GMThttp://www.aygfsteel.com/liuzheng/articles/150675.htmlhttp://www.aygfsteel.com/liuzheng/comments/150675.htmlhttp://www.aygfsteel.com/liuzheng/articles/150675.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/150675.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/150675.html


例子Q?br />
<class name="User" table="USER">
<composite-id name="userId" class="UserId">
<key-property name="userName"
column="USERNAME"/>
<key-property name="organizationId"
column="ORGANIZATION_ID"/>
</composite-id>
<version name="version"
column="VERSION"
unsaved-value="0"/>
<many-to-one name="organization"
class="Organization"
column="ORGANIZATION_ID"
insert="false" update="false"/>
...
</class>
public class UserId extends Serializable {
private String username;
private String organizationId;
public UserId(String username, String organizationId) {
this.username = username;
this.organizationId = organizationId;
}
// Getters...
public boolean equals(Object o) {
if (this == o) return true;
if (o = null) return false;
if (!(o instanceof UserId)) return false;----一般的判断开头都基本q样?/span>
final UserId userId = (UserId) o;
if (!organizationId.equals(userId.getOrganizationId()))
return false;
if (!username.equals(userId.getUsername()))
return false;
return true;
}
public int hashCode() {
return username.hashCode();
)
}
使用如下Q?br />
UserId id = new UserId("john", 42);
User user = new User();
// Assign a primary key value
user.setUserId(id);
// Set property values
user.setFirstname("John");
user.setLastname("Doe");
session.saveOrUpdate(user); // will save, since version is 0
session.flush();

刘铮 2007-10-06 11:37 发表评论
]]>
Hibernate中有关Interceptor的学?/title><link>http://www.aygfsteel.com/liuzheng/articles/145471.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Sun, 16 Sep 2007 02:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/145471.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/145471.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/145471.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/145471.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/145471.html</trackback:ping><description><![CDATA[可以使用Hibernate的InterceptorҎ据稽核,它避免了使用Lifecycle对Hibernate 的依赖。减了Hibernate的R入性?br /> 使用sessionFactory.openSession(interceptor)<br /> 使其与session相关联?br /> <br /> 但是常用的还是他的adaptorcEmptyInterceptor。我们只需要extends EmptyInterceptorQ然后针Ҏ们想要的Ҏq行override?br /> <br /> <br /> 注意QLifecycle和Interceptor都不能调用当前的sessionq行操作Q因Z们接口中定义的方法都是由当前session负责调用的,如果在这些方法中又调用了当前session的话Q就会导致管理؜乱。解x法有两种Q?。创Z个新的session。但是两个不同的session独占两个数据库连接,完成一个操作,对ƈ发量大的pȝ来说是个奢侈?。重用当前数据库q接。用session.connection()传递一个JDBC的ConnectionQ然后tempSession=sessionFactory.openSession(connection)Q这栯然是两个sessionQ但是只有一个数据库q接Q由于是׃n数据库连接,那么tempSession׃需要进行close()?br /> <img src ="http://www.aygfsteel.com/liuzheng/aggbug/145471.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-16 10:22 <a href="http://www.aygfsteel.com/liuzheng/articles/145471.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hibernate中Query查询问题http://www.aygfsteel.com/liuzheng/articles/145382.html刘铮 刘铮 Sat, 15 Sep 2007 08:14:00 GMThttp://www.aygfsteel.com/liuzheng/articles/145382.htmlhttp://www.aygfsteel.com/liuzheng/comments/145382.htmlhttp://www.aygfsteel.com/liuzheng/articles/145382.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/145382.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/145382.html join item.bids bid
where item.description like '%gc%'
and bid.amount > 100

q样得出来的是两个对?br /> item 和bid

通过q样q行查询
Query q = session.createQuery("from Item item join item.bids bid");
Iterator pairs = q.list().iterator();
Joining associations 263
while ( pairs.hasNext() ) {
Object[] pair = (Object[]) pairs.next();
Item item = (Item) pair[0];
Bid bid = (Bid) pair[1];
}


如果?br /> select item
from Item item
join item.bids bid
where item.description like '%gc%'
and bid.amount > 100
那么只得出的是一个对?

刘铮 2007-09-15 16:14 发表评论
]]>
Hibernate数据加蝲方式http://www.aygfsteel.com/liuzheng/articles/145379.html刘铮 刘铮 Sat, 15 Sep 2007 07:55:00 GMThttp://www.aygfsteel.com/liuzheng/articles/145379.htmlhttp://www.aygfsteel.com/liuzheng/comments/145379.htmlhttp://www.aygfsteel.com/liuzheng/articles/145379.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/145379.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/145379.html

1。立卛_?br /> 2。gq加?br /> 3。预先加?br /> 4。批量加?br />

对于延迟加蝲可以讄lazy="true"
对于预先加蝲可以在HQL中用out join 或者用left join fetch XXXQ其加?br />

刘铮 2007-09-15 15:55 发表评论
]]>
Hibernate的Persistent Object的深入理?/title><link>http://www.aygfsteel.com/liuzheng/articles/144914.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Thu, 13 Sep 2007 09:09:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/144914.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/144914.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/144914.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/144914.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/144914.html</trackback:ping><description><![CDATA[持久态对象是与session相关联的Q?br /> 只要session.saveQobjectQ,q个object便成Z持久态对象?br /> <br /> 注意session 是轻量的,他甚至不会得到JDBC Connection<br /> <br /> 当运行saveӞ一个对象便与session相关联了Q但是这个时候,q没有Q何SQL语句执行Q只有当session.flush()或事务transaction.commit()ӞHibernate得到一个JDBC ConnectionQ才真正的执行SQL语句Q这里意味着在save之后Q你q能对对象进行修攏V?br /> <br /> updateQ)也同理?br /> <img src ="http://www.aygfsteel.com/liuzheng/aggbug/144914.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-13 17:09 <a href="http://www.aygfsteel.com/liuzheng/articles/144914.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hibernate中一对多和多对一的配|?/title><link>http://www.aygfsteel.com/liuzheng/articles/144836.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Thu, 13 Sep 2007 05:40:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/144836.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/144836.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/144836.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/144836.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/144836.html</trackback:ping><description><![CDATA[一对多Q?br /> <br /> <set name="bids" inverse="true">--------------set表示集合  name为集合名也是javabean中的一个property<br />     <key column="ITEM_ID"/>          -------------key表示的ؓ外健 column表示对应的字D?br />     <one-to-many class="Bid"/>        -------------所对应的class<br /> </set><br /> <br /> inverse避免update ITEM_ID=XXX from Y where ITEM_ID=XXXX<br /> q样无意义的SQL语句<br /> <br /> 多对一Q?br /> <many-to-one<br /> name="item"                       ----javabean中的一个property<br /> column="ITEM_ID"            --在数据库中所对应的column<br /> class="Item"<br /> not-null="true"/> <br /> <br /> 所以在hibernate中都是双向配|,在one to many 一方设|inverse="true"<br /> q样的话Q在多方p自己理和一方的联系Q?br /> 所以在插入数据的时候就?Q多?add(一? <img src ="http://www.aygfsteel.com/liuzheng/aggbug/144836.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-13 13:40 <a href="http://www.aygfsteel.com/liuzheng/articles/144836.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>有关hibernate中的subclass的映?/title><link>http://www.aygfsteel.com/liuzheng/articles/144778.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Thu, 13 Sep 2007 03:17:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/144778.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/144778.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/144778.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/144778.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/144778.html</trackback:ping><description><![CDATA[W一U方法:使用一张表q且使用一个字D表明不同的subclass<br /> <discriminator<br /> column="XXXXX"<br /> type="XXXX"/><br /> 表示subclass的不同的地方Q?br /> column="XXXXX"为数据库中的区分column<br /> 如:<br /> <br /> <discriminator<br /> column="BILLING_DETAILS_TYPE"<br /> type="string"/><br /> <subclass<br /> name="CreditCard"<br /> discriminator-value="CC"><br /> <property<br /> name="type"<br /> column="CREDIT_CARD_TYPE"/><br /> ...<br /> </subclass><br /> W二U方法:使用多张表ƈ且用主外健关系<br /> <br /> <joined-subclass<br /> name="CreditCard"<br /> table="CREDIT_CARD"><br /> <key column="CREDIT_CARD_ID">----------<span style="color: red">外健<br /> </span><property<br /> name="type"<br /> column="TYPE"/><br /> ...<br /> </joined-subclass> <br /> <br /> W二U方式由于涉及到外健关系相联Q在取数据的时候会Ҏ据库资源的要求很? <img src ="http://www.aygfsteel.com/liuzheng/aggbug/144778.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-13 11:17 <a href="http://www.aygfsteel.com/liuzheng/articles/144778.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>hibernate中对象的3U状?---瞬时态、持久态、脱?http://www.aygfsteel.com/liuzheng/articles/143129.html刘铮 刘铮 Thu, 06 Sep 2007 03:44:00 GMThttp://www.aygfsteel.com/liuzheng/articles/143129.htmlhttp://www.aygfsteel.com/liuzheng/comments/143129.htmlhttp://www.aygfsteel.com/liuzheng/articles/143129.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/143129.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/143129.html
  •         瞬时?/strong>
  •         由new命o开辟内存空间的java对象Q?/p>

           eg. Person person = new Person("amigo", "?);

            如果没有变量对该对象q行引用Q它被java虚拟机回收?/p>

            瞬时对象在内存孤立存在,它是携带信息的蝲体,不和数据库的数据有Q何关联关p,在Hibernate中,可通过session的save()或saveOrUpdate()Ҏ瞬时对象与数据库相兌Qƈ数据对应的插入数据库中Q此时该瞬时对象转变成持久化对象?/p>

    •        持久?/strong>

            处于该状态的对象在数据库中具有对应的记录Qƈ拥有一个持久化标识。如果是用hibernate的delete()ҎQ对应的持久对象变成瞬时对象,因数据库中的对应数据已被删除Q该对象不再与数据库的记录关联?/p>

           当一个session执行close()或clear()、evict()之后Q持久对象变成脱对象,此时持久对象会变成脱对象,此时该对象虽然具有数据库识别|但它已不在HIbernate持久层的理之下?/p>

           持久对象h如下特点Q?/p>

           1. 和session实例兌Q?/p>

           2. 在数据库中有与之兌的记录?/p>

    •  q?/strong>

            当与某持久对象关联的session被关闭后Q该持久对象转变对象。当q对象被重新关联到session上时Qƈ再次转变成持久对象?/p>

           q对象拥有数据库的识别|可通过update()、saveOrUpdate(){方法,转变成持久对象?/p>

           q对象h如下特点Q?/p>

           1.  本质上与瞬时对象相同Q在没有M变量引用它时QJVM会在适当的时候将它回Ӟ

           2.  比瞬时对象多了一个数据库记录标识倹{?/p>

    刘铮 2007-09-06 11:44 发表评论
    ]]>
    վ֩ģ壺 | | | ʵ| | | | | | ־| | | ½| ƽ| | ֦| ӥ̶| ̫| | | | ±| ؿ˹| | ɽ| | | | ˮ| «Ϫ| | | | ±| | | ӱ| | | | |