日期:2014-05-20 浏览次数:20852 次
package com.hyb.bank.model; import java.util.Date; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToOne; @Entity public class Trade { private int ID; private Account accountID; private String tradeType; private double tradeMoney; private Date tradeTime; private String tradeDigest; @Id @GeneratedValue public int getID() { return ID; } public void setID(int iD) { ID = iD; } @ManyToOne public Account getAccountID() { return accountID; } public void setAccountID(Account accountID) { this.accountID = accountID; } public String getTradeType() { return tradeType; } public void setTradeType(String tradeType) { this.tradeType = tradeType; } public double getTradeMoney() { return tradeMoney; } public void setTradeMoney(double tradeMoney) { this.tradeMoney = tradeMoney; } public Date getTradeTime() { return tradeTime; } public void setTradeTime(Date tradeTime) { this.tradeTime = tradeTime; } public String getTradeDigest() { return tradeDigest; } public void setTradeDigest(String tradeDigest) { this.tradeDigest = tradeDigest; } }
package com.hyb.bank.dao; import java.util.List; import javax.annotation.Resource; import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.stereotype.Component; import com.hyb.bank.model.Account; import com.hyb.bank.model.Trade; @Component public class TradeDao { private HibernateTemplate hibernateTemplate; public List<Trade> loadReamining(String accountID){ List<Trade> trades = hibernateTemplate.find ("from Trade t where t.accountID='"+accountID+"'"); return trades; } public HibernateTemplate getHibernateTemplate() { return hibernateTemplate; } @Resource public void setHibernateTemplate(HibernateTemplate hibernateTemplate) { this.hibernateTemplate = hibernateTemplate; } }