想用<set  batch-size="10">的功能去批量实例化集合的实例,但是在控制台输出的SQL代码来看还是没有变化,产生的select语句还是实例化一个TblReply对象执行一条select语句,不知道什么原因batch-size="10"属性不起作用,我看《精通Hibernate》这本书里面的教程都可以,下面是我的代码,代码有点长,麻烦大家帮忙解决,急切学习中:
TblTopic.hbm.xml:
<?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.good.hibernate.entity.TblTopic" table="TBL_TOPIC" batch-size="10" schema="dbo" catalog="bbs">
        <id name="topicId" type="java.lang.Integer">
            <column name="topicId" />
            <generator class="increment" />
        </id>
        
        <many-to-one name="tblUser" class="com.good.hibernate.entity.TblUser" lazy="false">
            <column name="uId" not-null="true" />
        </many-to-one>
        
        <many-to-one name="tblBoard" class="com.good.hibernate.entity.TblBoard">
            <column name="boardId" not-null="true" />
        </many-to-one>
        
        <set name="tblReplys" batch-size="3" inverse="true" lazy="true">
         <key column="topicId"></key>
         <one-to-many class="com.good.hibernate.entity.TblReply"/>
        </set>
        
        <property name="title" type="java.lang.String">
            <column name="title" length="50" not-null="true" />
        </property>
        <property name="content" type="java.lang.String">
            <column name="content" length="1000" not-null="true" />
        </property>
        <property name="publishTime" type="java.util.Date">
            <column name="publishTime" length="23" not-null="true" />
        </property>
        <property name="modifyTime" type="java.util.Date">
            <column name="modifyTime" length="23" not-null="true" />
        </property>
    </class>
    <query name="getTopics">
     from TblTopic tblTopic
     left join fetch tblTopic.tblUser
     where tblTopic.tblBoard.boardId=:boardId
    </query>
</hibernate-mapping>
===============================================================================
===============================================================================
实例类。
TblTopic.java:public class TblTopic {
private Integer topicId;
private String title;
private String content;
private Date publishTime;
private Date modifyTime;
private TblUser tblUser;
private TblBoard tblBoard;
private Set<TblReply> tblReplys = new HashSet<TblReply>();
private int tblReplysSize;

public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}


public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}


public Date getPublishTime() {
return publishTime;
}
public void setPublishTime(Date publishTime) {
this.publishTime = publishTime;
}


public TblBoard getTblBoard() {
return tblBoard;
}
public void setTblBoard(TblBoard tblBoard) {
this.tblBoard = tblBoard;
}


public TblUser getTblUser() {
return tblUser;
}
public void setTblUser(TblUser tblUser) {
this.tblUser = tblUser;
}


public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}


public Integer getTopicId() {
return topicId;
}
public void setTopicId(Integer topicId) {
this.topicId = topicId;
}


public Set<TblReply> getTblReplys() {
return tblReplys;
}
public void setTblReplys(Set<TblReply> tblReplys) {
this.tblReplys = tblReplys;
try {
setTblReplysSize(tblReplys.size());
} catch (Exception e) {
// TODO: handle exception
}

}


public int getTblReplysSize() {
return tblReplysSize;
}
public void setTblReplysSize(int tblReplysSize) {
this.tblReplysSize = tblReplysSize;
}
}==========================================================================================
==========================================================================================
调用HQL的代码
Service.java:public class Service {
public List<TblTopic> getTopicList(int boardId) {
Session session = HibernateSessionFactory.getSession();
Transaction tran = null;
List<TblTopic> tblTopics = null;
try {
Query query = session.getNamedQuery("getTopics");
query.setInteger("boardId",boardId);
tblTopics = query.list();
} catch (Exception e) {
tran.rollback();
}finally{
session.close();
}
return tblTopics;
}
}