跳到主要內容

Hibernate Find By Example

當TB_FD_USER裡面的PK=USER_NO時候
只有放PK到findByExample會被忽略喔...

eStoreService dao = (eStoreService)SpringService.getService(SpringService.USE_JDBC, "eStoreService");
TbFdUser user = new TbFdUser();
user.setUserNo(new Long(1));
Collection c = dao.getUserByExample(user);
System.out.println("result size:"+c.size());

Result...
Hibernate: select this_.USER_NO as USER1_4_0_, this_.ADDRESS as ADDRESS4_0_, this_.AREA_CODE as AREA3_4_0_, this_.BANK_ACCOUNT as BANK4_4_0_, this_.BIRTHDAY as BIRTHDAY4_0_, this_.CITY as CITY4_0_, this_.COMPANY_NAME as COMPANY7_4_0_, this_.COUNTRY_CODE as COUNTRY8_4_0_, this_.CREATE_BY as CREATE9_4_0_, this_.CREATE_DATE as CREATE10_4_0_, this_.EMAIL as EMAIL4_0_, this_.FAX_NO as FAX12_4_0_, this_.FLAG as FLAG4_0_, this_.ID_NO as ID14_4_0_, this_.INTRODUCED_BY as INTRODUCED15_4_0_, this_.LOGIN_ID as LOGIN16_4_0_, this_.LOGIN_PWD as LOGIN17_4_0_, this_.MOBILE_NO as MOBILE18_4_0_, this_.PROVINCE_CODE as PROVINCE19_4_0_, this_.SEX as SEX4_0_, this_.STATUS as STATUS4_0_, this_.TEL_NO as TEL22_4_0_, this_.TITLE as TITLE4_0_, this_.UPDATE_BY as UPDATE24_4_0_, this_.UPDATE_DATE as UPDATE25_4_0_, this_.USER_NAME as USER26_4_0_, this_.USER_TYPE as USER27_4_0_ from tb_fd_user this_ where (1=1)
result size:3


eStoreService dao = (eStoreService)SpringService.getService(SpringService.USE_JDBC, "eStoreService");
TbFdUser user = new TbFdUser();
user.setUserNo(new Long(1));
user.setEmail("xxx@ooo.com");
Collection c = dao.getUserByExample(user);
System.out.println("result size:"+c.size());

Result...
Hibernate: select this_.USER_NO as USER1_4_0_, this_.ADDRESS as ADDRESS4_0_, this_.AREA_CODE as AREA3_4_0_, this_.BANK_ACCOUNT as BANK4_4_0_, this_.BIRTHDAY as BIRTHDAY4_0_, this_.CITY as CITY4_0_, this_.COMPANY_NAME as COMPANY7_4_0_, this_.COUNTRY_CODE as COUNTRY8_4_0_, this_.CREATE_BY as CREATE9_4_0_, this_.CREATE_DATE as CREATE10_4_0_, this_.EMAIL as EMAIL4_0_, this_.FAX_NO as FAX12_4_0_, this_.FLAG as FLAG4_0_, this_.ID_NO as ID14_4_0_, this_.INTRODUCED_BY as INTRODUCED15_4_0_, this_.LOGIN_ID as LOGIN16_4_0_, this_.LOGIN_PWD as LOGIN17_4_0_, this_.MOBILE_NO as MOBILE18_4_0_, this_.PROVINCE_CODE as PROVINCE19_4_0_, this_.SEX as SEX4_0_, this_.STATUS as STATUS4_0_, this_.TEL_NO as TEL22_4_0_, this_.TITLE as TITLE4_0_, this_.UPDATE_BY as UPDATE24_4_0_, this_.UPDATE_DATE as UPDATE25_4_0_, this_.USER_NAME as USER26_4_0_, this_.USER_TYPE as USER27_4_0_ from tb_fd_user this_ where (this_.EMAIL=?)
result size:1

這個網誌中的熱門文章

Oracle LISTAGG

同事介紹的一個Oracle的好用查詢:LISTAGG
SELECT A.GROUP_ID,A.KEY, LISTAGG(A.VALUE,'; ')WITHINGROUP(ORDERBYA.VALUE)as GG  fromSYS_PROPERTIESaGROUP byA.GROUP_ID,A.KEY
LISTAGG可以將group後的結果會總顯示於一個欄位 上述SQL原本A.VALUE會是一個row一個row的排列 使用LISTAGG之後,可以將A.VALUE顯示在同一個row中 並且可以指定間隔符號(在此設定為';') 針對某一些報表查詢非常有用唷 :D

使用GCP Cloud Builder建置CI/CD Flow

服務的建置通常是持續性的作業,而部署則一般是專案初期建置一次,未來可以沿用該部署設定... 這樣的流程走向自動化,在Container的環境又更是重要... 本篇介紹一下,在Google雲端,我們可以搭配Source Repository與Build Trigger等服務來完成服務的自動建置與部屬,讓封裝Container與部署到Container Engine的動作可以一氣呵成...
首先幾單瞭解一下一個Container Engine服務的建置與部屬過程...
使先,建立Container Engine Cluster,透過GCP Winzard可以很快速地開立您的GKE Cluster…

假設您的cluster是叫做demo-cluster,則可以透過下面的指令來跟GKE建立連線
$ gcloud container clusters get-credentials demo-cluster --zone asia-east1-a
這串指令不用記ㄛ~可以在Cluster的頁面找到他...

點選複製,即可貼到您的Terminal執行...

跟GKE建立鏈結後,接下來可以部署您的城市,這邊我們以我的一個範例程式Demoweb (https://github.com/peihsinsu/demoweb) 為例,

這個專案中,包含幾個重要結構:
app/ : 放置您的程式,在Dockerfile中會將該資料匣複製到Docker Image中 k8s/ : 放置k8s的deployment與service描述檔 Dockerfile : 封裝docker的描述檔,會以node.js的image為基礎來建置執行環境 cloudbuild.yaml : Google Cloud Build Trigger的步驟描述檔

使用 minikube 輕鬆上手 kubernetes

安裝minikube
macOS只需要透過brew即可快速安裝...
brew cask install minikube
Linux環境可以直接下載執行檔,放到環境變數可以吃到的路徑即可...
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && \ chmod +x minikube && \
sudo mv minikube /usr/local/bin/
Windows的下載網址如下: https://storage.googleapis.com/minikube/releases/latest/minikube-windows-amd64.exe
如果您的kubectl尚未安裝,可以直接使用google cloud sdk來安裝:
curl https://sdk.cloud.google.com | bash
gcloud components install kubectl
安裝完成後,原則上minikube會在本地端加入minikube的k8s context,我們可以透過下面指令來使用該context…
kubectl config use-context minikube
然後,可檢查一下您的minikube node是否正常運作....