映射文件
<hibernate-mapping package="com.zdvictory.wjj.pricesend.view" default-lazy="true">
<class name="PcServerObject" table="PC_SERVER_OBJECT" dynamic-insert="true" dynamic-update="true">
<id name="so_id" column="SO_ID">
<generator class="uuid.hex">
</generator>
</id>
<property name="so_servicename" column="SO_SERVICENAME"/>
<property name="so_linktel" column="SO_LINKTEL"/>
<property name="so_linkfax" column="SO_LINKFAX"/>
<property name="so_linkmail" column="SO_LINKMAIL"/>
<property name="so_linkaddress" column="SO_LINKADDRESS"/>
<property name="so_medium" column="SO_MEDIUM"/>
<property name="so_class" column="SO_CLASS"/>
<set name="pcDataHistoryRefers" lazy="true" inverse="true">
<key column="so_id"></key>
<one-to-many class="PcDataHistoryRefer" />
</set>
</class>
</hibernate-mapping>
<hibernate-mapping package="com.zdvictory.wjj.pricesend.view" default-lazy="true">
<class name="PcDataHistoryRefer" table="PC_DATA_HISTORY_REFER" dynamic-insert="true" dynamic-update="true">
<id name="dhr_id" column="DHR_ID">
<generator class="uuid.hex">
</generator>
</id>
<property name="so_id" column="SO_ID"/>
<property name="dhr_medium" column="DHR_MEDIUM"/>
<property name="dhr_referstate" column="DHR_REFERSTATE"/>
<property name="dhr_refertime" column="DHR_REFERTIME"/>
<many-to-one name="pcServerObject" column="so_id"/>
</class>
</hibernate-mapping>
action里面的方法
public String list() throws Exception {
//今日发送情况
List sendList=getPcServerObjectService().findPcServerObject();
request.setAttribute("sendList", sendList);
return SUCCESS;
}
jsp页面取值
<%List sendList=(List)request.getAttribute("sendList");
int amount=sendList.size();
for(int j=0;j<amount;j++){
PcServerObject pcServerObject=(PcServerObject)sendList.get(j);
if(pcServerObject!=null){
%>
<tr bgcolor="#ffffff">
<td align="center"><%=j+1 %></td>
<td><%switch(pcServerObject.getSo_class()){
case 0:out.print("国家");break;
case 1:out.print("省级");break;
case 2:out.print("媒体");break;
case 3:out.print("市场");break;
} %></td>
<td><%=pcServerObject.getSo_servicename() %></td>
<%String referTime="";
for(Iterator iter=pcServerObject.getPcDataHistoryRefers().iterator();iter.hasNext();){
PcDataHistoryRefer pdhr=(PcDataHistoryRefer)iter.next();
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
String cTime=format.format(Calendar.getInstance().getTime());