Hibernate对视图的操作
Hibernate对视图进行操作时和对普通的表有些不同,下面就是一个Hibernate操作视图的例子:视图:
SELECT a.SPID, a.SPKey, b.serviceID, b.serviceName, c.serviceItemID, c.itemName
FROM dbo.tbSPInfo a
INNER JOIN dbo.tbService b ON a.SPID = b.SPID LEFT OUTER JOIN
dbo.tbServiceItem c ON b.serviceID = c.serviceID
1.首先根据视图中的字段定义一个bean
<div style="padding: 4px 5.4pt; width: 95%;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifpackage com.txsec.lc.is.bean;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifimport java.io.Serializable;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gifpublic class ServiceId implements Serializable {
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif private static final long serialVersionUID = -2298938310945830572L;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif private String spId;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif private String spKey;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif private String serviceId;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif private String serviceName;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif private String serviceItemId;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif private String itemName;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public ServiceId() ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif super();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public String getItemName() ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return itemName;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public void setItemName(String itemName) ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif this.itemName = itemName;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public String getServiceId() ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return serviceId;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public void setServiceId(String serviceId) ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif this.serviceId = serviceId;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public String getServiceItemId() ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return serviceItemId;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public void setServiceItemId(String serviceItemId) ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif this.serviceItemId = serviceItemId;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public String getServiceName() ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return serviceName;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public void setServiceName(String serviceName) ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif this.serviceName = serviceName;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public String getSpId() ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return spId;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public void setSpId(String spId) ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif this.spId = spId;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public String getSpKey() ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return spKey;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif public void setSpKey(String spKey) ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif this.spKey = spKey;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif...
页:
[1]