67,513
社区成员
发帖
与我相关
我的任务
分享
<?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 - Hibernate Tools
-->
<hibernate-mapping>
<class name="Bei.Google.PM.XML.vo.Newtracking" table="newtracking" schema="SCOTT">
<id name="jobid" type="java.lang.String">
<column name="JOBID" length="16" />
<generator class="assigned">
</generator>
</id>
<property name="csvendor" type="java.lang.String" >
<column name="CSVENDOR" length="32" not-null="false" />
</property>
<property name="ctvendor" type="java.lang.String">
<column name="CTVENDOR" length="32" not-null="false" />
</property>
<property name="newhodate" type="java.lang.String">
<column name="NEWHODATE" length="32" not-null="true" />
</property>
<property name="newhbdate" type="java.lang.String">
<column name="NEWHBDATE" length="32" not-null="true" />
</property>
<property name="wordcount" type="java.lang.String">
<column name="WORDCOUNT" length="32" not-null="true" />
</property>
<joined-subclass name="Bei.Google.PM.XML.vo.NewStatus" table="newstatus">
<key column ="JOBID"/>
<property name="jobstatus" type="java.lang.String" column="jobstatus"></property>
<property name="csstatus" type="java.lang.String" column="csstatus"></property>
<property name="ctstatus" type="java.lang.String" column="ctstatus"></property>
</joined-subclass>
<joined-subclass name="Bei.Google.PM.XML.vo.NewVendorDeliverTime" table="newvendordelivertime">
<key column ="JOBID"/>
<property name="cntime" type="java.lang.String" column="cntime"></property>
<property name="cttime" type="java.lang.String" column="cttime"></property>
</joined-subclass>
</class>
</hibernate-mapping>
package Bei.Google.PM.XML.vo;
public class Newtracking
private String jobid;
private String csvendor;
private String ctvendor;
private String newhodate;
private String newhbdate;
private String wordcount;
public String getCsvendor() {
return csvendor;
}
public void setCsvendor(String csvendor) {
this.csvendor = csvendor;
}
public String getCtvendor() {
return ctvendor;
}
public void setCtvendor(String ctvendor) {
this.ctvendor = ctvendor;
}
public String getJobid() {
return jobid;
}
public void setJobid(String jobid) {
this.jobid = jobid;
}
public String getNewhbdate() {
return newhbdate;
}
public void setNewhbdate(String newhbdate) {
this.newhbdate = newhbdate;
}
public String getNewhodate() {
return newhodate;
}
public void setNewhodate(String newhodate) {
this.newhodate = newhodate;
}
public String getWordcount() {
return wordcount;
}
public void setWordcount(String wordcount) {
this.wordcount = wordcount;
}
}
package Bei.Google.PM.XML.vo;
public class NewStatus extends Newtracking {
private String jobstatus ;
private String csstatus ;
private String ctstatus ;
public String getJobstatus() {
return jobstatus;
}
public void setJobstatus(String jobstatus) {
this.jobstatus = jobstatus;
}
public String getCsstatus() {
return csstatus;
}
public void setCsstatus(String csstatus) {
this.csstatus = csstatus;
}
public String getCtstatus() {
return ctstatus;
}
public void setCtstatus(String ctstatus) {
this.ctstatus = ctstatus;
}
}
package Bei.Google.PM.XML.vo;
public class NewVendorDeliverTime extends Newtracking {
private String cntime ;
private String cttime ;
public String getCntime() {
return cntime;
}
public void setCntime(String cntime) {
this.cntime = cntime;
}
public String getCttime() {
return cttime;
}
public void setCttime(String cttime) {
this.cttime = cttime;
}
}
package Bei.Google.PM.NewSearch.impl;
import java.util.*;
import org.hibernate.Query;
import org.hibernate.Session;
import Bei.Google.PM.NewSearch.vo.NewinfoSearchDTO;
import Bei.Google.PM.XML.vo.NewStatus;
import Bei.Google.PM.XML.vo.NewVendorDeliverTime;
import Bei.Google.PM.XML.vo.Newtracking;
public class NewInfoSearchimpl implements NewSearchDAO {
private Session session;
public NewInfoSearchimpl() {
this.session = SessionFactory.getSession();
}
public boolean isSearch(NewinfoSearchDTO newinfosearchdto) throws Exception {
boolean flag = false;
Newtracking nt = null;
String hql = "FROM Newtracking as t where t.jobid=?";
Query q = session.createQuery(hql);
q.setString(0, newinfosearchdto.getJobid());
Iterator iter = q.list().iterator();
if (iter.hasNext()) {
nt = (Newtracking) iter.next();
flag = true;
NewStatus ns = (NewStatus) nt;
NewVendorDeliverTime nvdt = (NewVendorDeliverTime) nt;
String lc = newinfosearchdto.getLanguagecode();
if ("zh-CN".equals(lc)) {
newinfosearchdto.setStatus(ns.getCsstatus());
newinfosearchdto.setVendor(nt.getCsvendor());
newinfosearchdto.setVendorhbd(nvdt.getCntime());
newinfosearchdto.setWordcount(nt.getWordcount());
} else if ("zh-TW".equals(lc)) {
newinfosearchdto.setStatus(ns.getCtstatus());
newinfosearchdto.setVendor(nt.getCtvendor());
newinfosearchdto.setVendorhbd(nvdt.getCttime());
newinfosearchdto.setWordcount(nt.getWordcount());
}
}
return flag;
}
}
public class NewInfoSearchimpl implements NewSearchDAO {
private Session session;
public NewInfoSearchimpl() {
this.session = SessionFactory.getSession();
}
public boolean isSearch(NewinfoSearchDTO newinfosearchdto) throws Exception {
boolean flag = false;
Newtracking nt = null;
String hql = "FROM Newtracking as t where t.jobid=?";
Query q = session.createQuery(hql);
q.setString(0, newinfosearchdto.getJobid());
Iterator iter = q.list().iterator();
if (iter.hasNext()) {
nt = (Newtracking) iter.next();//这里会得到Newtracking类的一个实例nt
//这个实例nt可能是NewStatus
//也可能是NewVendorDeliverTime
flag = true;
NewStatus ns = (NewStatus) nt; //那么这行就有问题了
//如果nt是NewVendorDeliverTime的话
//这里就会甩出ClassCastException
NewVendorDeliverTime nvdt = (NewVendorDeliverTime) nt; //同理这行也有问题了
//如果nt是NewStatus的话
//这里就会甩出ClassCastException
//根据以上分析,上面那两行代码可改为:
//NewStatus ns = null;
//NewVendorDeliverTime nvdt = null;
//if(nt instanceof NewStatus){
// ns = (NewStatus) nt
//}else if(nt instanceof NewVendorDeliverTime) {
// nvdt = (NewVendorDeliverTime) nt;
//}
//这样下面的代码也要做相应修改
String lc = newinfosearchdto.getLanguagecode();
if ("zh-CN".equals(lc)) {
newinfosearchdto.setStatus(ns.getCsstatus());
newinfosearchdto.setVendor(nt.getCsvendor());
newinfosearchdto.setVendorhbd(nvdt.getCntime());
newinfosearchdto.setWordcount(nt.getWordcount());
} else if ("zh-TW".equals(lc)) {
newinfosearchdto.setStatus(ns.getCtstatus());
newinfosearchdto.setVendor(nt.getCtvendor());
newinfosearchdto.setVendorhbd(nvdt.getCttime());
newinfosearchdto.setWordcount(nt.getWordcount());
}
}
return flag;
}
}