daoでカスタムリターンエンティティ
1962 ワード
1)javaオブジェクト
2)Daoのコード
注意:
a)@queryのSplashItemにはパッケージ名が必要です
b)Daoのnew com.cvt.smarthome.application.advertisement.entity.apiEntity.SplashItem(t.id,t.enabledTime,t.eTag)はjavaクラスオブジェクトのコンストラクション関数public SplashItem(long splashId,Calendar enabledTime,String eTag)に対応する.
public class SplashItem {
public String url;
public long enabledTime;
public long splashId;
public String eTag;
public SplashItem(long splashId, long enabledTime) {
this.splashId = splashId;
this.enabledTime = enabledTime;
}
public SplashItem(long splashId, Calendar enabledTime, String eTag) {
this.splashId = splashId;
this.enabledTime = enabledTime.getTimeInMillis();
this.eTag = eTag;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public long getEnabledTime() {
return enabledTime;
}
public void setEnabledTime(long enabledTime) {
this.enabledTime = enabledTime;
}
public long getSplashId() {
return splashId;
}
public void setSplashId(long splashId) {
this.splashId = splashId;
}
public String geteTag() {
return eTag;
}
public void seteTag(String eTag) {
this.eTag = eTag;
}
}
2)Daoのコード
@Query(value = "select new com.cvt.smarthome.application.advertisement.entity.apiEntity.SplashItem(t.id,t.enabledTime,t.eTag) from SplashSetting t where t.terminalType.id=?1 and t.appkey =?2 and t.resolutionWidth =?3 and t.resolutionHeight=?4 order by t.enabledTime desc ")
public List<SplashItem> find2LastSplash(Long terminalTypeId, String appkey, Long resolutionWidth,
Long resolutionHeight, Pageable pageable);
注意:
a)@queryのSplashItemにはパッケージ名が必要です
b)Daoのnew com.cvt.smarthome.application.advertisement.entity.apiEntity.SplashItem(t.id,t.enabledTime,t.eTag)はjavaクラスオブジェクトのコンストラクション関数public SplashItem(long splashId,Calendar enabledTime,String eTag)に対応する.