UEP-find查询

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UEP-find查询相关的知识,希望对你有一定的参考价值。

 1   实体类:
 2   @Entity
 3   @Table(name = "xxxxx")
 4   public class WzInitializeStoreInfo extends EntityBean{
 5      private static final long serialVersionUID = 1L;
 6     //字段都需要get、set方法
 7      @Id
 8       @Column(name = "INCODE")
 9     private Long incode;
10      @Column(name = "BATCH_ID")
11     private Long batchId;
12      @Column(name = "VALID_DATE")
13      private Timestamp validDate;
14 
15      //其他表的字段
16     @Transient
17      private String modelDesc;//无参参构造方法
18      public WzInitializeStoreInfo(){}
19     //有参构造方法
20      public WzInitializeStoreInfo(Long incode, Long batchId, 
21              String modelDesc,Date validDate) {
22         super();
23          this.incode = incode;
24          this.batchId = batchId;
25          this.modelDesc=modelDesc;
26         this.validDate = (Timestamp)validDate;
27      } 
28     public Long getIncode() {
29          return incode;
30      }
31      public void setIncode(Long incode){
32          this.incode = incode;
33      }
34      public String getModelDesc() {
35          return modelDesc;
36      }
37  
38     public void setModelDesc(String modelDesc) {
39          this.modelDesc = modelDesc;
40     }
41  
42      @Override
43     public Record exportToRecord() {
44          EntityMetaData metaData =  EntityMetaDataUtil.getEntityMetaData(this.getClass().getName());
45          if (metaData == null) {
46              new BaseRunException("Java类"+this.getClass().getName()+"没有元数据信息!不能导出为Record!").handle();
47         }
48          Record record = PrintUtil.genEmptyExportRecord(metaData);
49          record.set("INCODE", this.incode);
50          record.set("BATCH_ID", this.batchId);
51          return record;
52      }  
53  }
54  Ipml  
55  @Component("wzInitializeStoreInfoDetailService")
56  public class WzInitializeStoreInfoDetailServiceImpl implements WzInitializeStoreInfoDetailService {  
57      IDAO supplyDAO = JPAUtil.useJPATool("SupplyChainJPAToolDAO");//仓储用户     
58      public List<WzInitializeStoreInfo> retrieve(QueryParamList param, PageInfo pageInfo,SortParamList sort) throws BaseRunException {      
59          StringBuffer jpql=new StringBuffer();
60         jpql.append("select new com.haiyisoft.entity.wz.WzInitializeStoreInfo(w.incode,w.batchId,c.modelDesc,w.
61   validDate)"); 68 jpql.append(" from WzInitializeStoreInfo w,WzCode c where w.incode=c.incode " + "AND w.storeId in ("+StoreCommonUtil.getLowStoreStr(((AdminView)ContextUtil.getUserView()).getOrgPartyId())+")"); //查询自己仓库的数据  70  } 71 if(param.get("batchId")!=null){ 72 jpql.append(" and w.batchId=:batchId"); 73  } 74 if(param.get("modelDesc")!=null){ 75 jpql.append(" and c.modelDesc like :modelDesc"); 76  } 78 jpql.append(" order by w.batchId desc"); 80 List<Object> list=supplyDAO.find(jpql.toString(),param, sort,pageInfo); 82 List<WzInitializeStoreInfo> siteList=new ArrayList<WzInitializeStoreInfo>(); 83 for(int i=0;i<list.size();i++){ 84  siteList.add((WzInitializeStoreInfo)list.get(i)); 85  } 86 return siteList; 87 88  } 89 }
62   注意事项:
63     ①构造方法的字段名、顺序、个数,要与查询语句的一致
64     ②查询方法中要加入主键
65     ③在实体类中要有无参的构造方法和有参数的构造方法
      ④如果代码中涉及到时间类型,注意时间类型的转换
     
⑤ com.haiyisoft.entity.wz.WzInitializeStoreInfo实体类全路径
  模糊查询:

    if(param.get("wzName")!=null){

      ①jpql.append(" and c.wzName like "+"‘"+param.get("wzName").getValue()+"‘");

    或者: ②jpql.append(" and c.wzName like wzName ‘‘);

    }

       ②List<Object> list=supplyDAO.find(jpql.toString(), param,sort,pageInfo);

    注意   ①和②的差别,①如果传参数会报找不到相应字段的错误

  

 

以上是关于UEP-find查询的主要内容,如果未能解决你的问题,请参考以下文章

Microsoft SQL Server 代码片段收集

片段视图返回后执行的 Firebase 查询

在 Java 的 GraphQL 查询中添加片段

推进学说代码片段

sql [SQL查询片段]用于在命令行或通过R和其他工具使用SQL的快速代码段#tags:sql,R,text processing,命令li

Huawei_Netconf_Ncclient