Total Pageviews

2015/06/01

[閱讀筆記] 問題不能拆開來看

  1. 核心問題會一直存在的理由,是因為過去曾採取的矯正行動,導致其他不良效應
  2. 夏目漱石:過於理智,容易與人摩擦;順從感情,易遭情緒左右;固持己見,終至窮途末路。總而言之,人世難以安居
  3. 所謂的問題,就是目標與現況之間的落差、預期與實際之間的落差
  4. Edwards Deming曾說:品質是生產流程中創造出來的。然而,利潤是流程產生的結
  5. 達爾文曾說:能生存下來的物種,既非最強,也非最具智慧,而是那些最能適應變化的物種  
  6. 唯有提出正確的質問,才能導出正確的解決對策
  7. 在進行成本削減活動的情況下,又針對各個專案的個別損益狀況進行績效評量,開會次數與報告書就會變多,因此最重要的工作反而無法進行。而且工作場所的工作氣氛若變得惡劣,員工的工作動機也會跟著下降
  8. 正確的定義問題,問題就解決了一半
  9. 所謂的策略,是對於"為何而作"的疑問提供解答;所謂的戰術,是對於"怎麼去做"的疑問提供解答
  10. 組織越大,最高決策階層與第一線的工作人員溝通鴻溝越大,導致第一線人員搞不清楚高層的策略與戰術,不知為何而戰
  11. 凡人會從自己的失敗中學習,賢人會從他人的失敗中學習
  12. 不做給對方看、不說給對方聽、不讓對方嘗試、不誇獎對方、人則不為所動
  13. 限制理論有五大核心步驟:
    1. 找出系統中存在哪些限制
    2. 尋找突破這些限制的辦法
    3. 突破限制的措施將優先於系統的所有其他活動
    4. 具體實施步驟二提出的措施,使步驟一找出的限制不再是約束企業
    5. 回到步驟一,持續尋找、改善限制,謹防惰性成為系統的約束

[Git] Why is the egit merge tool disabled in Eclipse

Problem
After I create a merge request in GitLab, GitLab remind me this branch cannot be merged automatically.

As I open context menu from my project and try to resolve conflict issues, select Team --> Merge. But the menu option had been disabled.


Solution
1. Change to Git perspective. Branches => Remote Tracking => origin/master

2. Open context menu => Synchronize with Workspace

3. The conflict list is the source code which had been marked red.























4. Fix the foregoing conflict problems and open context menu => Marked as Merged

5. After fixed conflict problems, then push and commit to master again.

2015/05/31

2015/05 Travel

嘉義市立棒球場


光之穹頂 Dome of Light






高雄願景橋




阿勃勒




從忠烈祠鳥瞰高雄


高雄市總圖



鳳儀書院

2015/05/19

[JPA] timestamp does not save into database

Problem
Here is my entity
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
@Entity
public class Dbm100f1 implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @SequenceGenerator(name = "DBM100F1_REVIEWSEQNO_GENERATOR", sequenceName = "SE_DBM_DBM100F1")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DBM100F1_REVIEWSEQNO_GENERATOR")
    @Column(name = "REVIEW_SEQ_NO")
    private long reviewSeqNo;
 
    @Temporal(TemporalType.DATE)
    @Column(name = "CREATE_DATE")
    private Date createDate;
 
    @Temporal(TemporalType.DATE)
    @Column(name = "UPDATE_DATE")
    private Date updateDate;
 
    //ignore other fields and getter/setter methods

|

But as I save this entity into database, it save date only exclude time.
Solution
Change the TemporalType
  • TemporalType.DATE : represents date only (e.g. 2015/05/19).
  • TemporalType.TIME : represents time only (e.g. 10:28:34).
  • TemporalType.TIMESTAMP : represents date and time (e.g. 2015/05/19 10:28:34).

Theorefore, amend the entity as bellowing:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
@Entity
public class Dbm100f1 implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @SequenceGenerator(name = "DBM100F1_REVIEWSEQNO_GENERATOR", sequenceName = "SE_DBM_DBM100F1")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DBM100F1_REVIEWSEQNO_GENERATOR")
    @Column(name = "REVIEW_SEQ_NO")
    private long reviewSeqNo;
 
    @Temporal(TemporalType.TIMESTAMP )
    @Column(name = "CREATE_DATE")
    private Date createDate;
 
    @Temporal(TemporalType.TIMESTAMP )
    @Column(name = "UPDATE_DATE")
    private Date updateDate;
 
    //ignore other fields and getter/setter methods

|


Then the create_date and update_date can save date and time now.


Reference
[1] http://www.objectdb.com/java/jpa/entity/types#Date_and_Time_Temporal_Types_

2015/05/11

[Apache POI] How to read empty row in excel file

Problem
Here is my excel file

I will read excel from top to down, and will start to read from row 4 and write data into database.
Here is my code snippet:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 // file extension validation
 String extension = StringUtils.upperCase(FilenameUtils.getExtension(fileName));
 Integer startingRow = 3;
 
 Workbook workbook = null;
 Sheet sheet = null;

 if ("XLS".equals(extension)) {
     // Get the workbook instance for XLS file
     workbook = new HSSFWorkbook(inputStream);
 } else if ("XLSX".equals(extension)) {
     // Get the workbook instance for XLSX file
     workbook = new XSSFWorkbook(inputStream);
 } else {
     String errorMsg = "只接受副檔名為xls與xlsx的檔案, fileName = " + fileName;
     throw new RuntimeException(errorMsg);
 }

 // Get the specific sheet from the workbook
 sheet = workbook.getSheetAt(0);

 Iterator<Row> rowIterator = sheet.iterator();
 int rowCount = 0;
 while (rowIterator.hasNext()) {
     Row row = rowIterator.next();
     if (rowCount < startingRow) {
     //do nothing
     } else {
     //start to read and write data into database
     }
     rowCount++;
 }

But, apply this approach it will read from row 5. Because of the first row is null, Apache POI will skip empty row.

Solution
Utilize for-loop instead of while-loop, then it will not skip empty row:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  // file extension validation
 String extension = StringUtils.upperCase(FilenameUtils.getExtension(fileName));
 Integer startingRow = 3;

 Workbook workbook = null;
 Sheet sheet = null;

 if ("XLS".equals(extension)) {
     // Get the workbook instance for XLS file
     workbook = new HSSFWorkbook(inputStream);
 } else if ("XLSX".equals(extension)) {
     // Get the workbook instance for XLSX file
     workbook = new XSSFWorkbook(inputStream);
 } else {
     String errorMsg = "只接受副檔名為xls與xlsx的檔案, fileName = " + fileName;
     throw new RuntimeException(errorMsg);
 }

 // Get the specific sheet from the workbook
 sheet = workbook.getSheetAt(0);

 // get last row number
 int rowEnd = sheet.getLastRowNum();

 for (int rowNum = startingRow; rowNum <= rowEnd; rowNum++) {
     Row row = sheet.getRow(rowNum);
    
 }


Reference
[1] http://poi.apache.org/spreadsheet/quick-guide.html#Iterator

2015/05/07

[Oracle] How do I get column's data type in Oracle

Problem
If I have table name and column name, how do I get its data type in database?


Solution
Here is the sql statement to retrieve column's data type
1
2
3
4
SELECT DATA_TYPE
FROM all_tab_columns
WHERE upper(TABLE_NAME) = :TABLE_NAME
  AND upper(COLUMN_NAME) = :COLUMN_NAME


Execution result:



Reference
[1] http://stackoverflow.com/questions/2339053/how-do-i-get-column-datatype-in-oracle-with-pl-sql-with-low-privileges

2015/05/05

[iReport] Remove Pagination

Problem
I am using iReport as my report design tool. And export to excel report as bellows:

It apply pagination feature in excel file, so it reprint column header again. 
Therefore, we need to remove pagination in this report.

Solution
Click report in iReport

Check "ignore pagination" attribute

Check result

Reference
[1] http://jeffeske.com/blog/ireport-removing-pagination/

2015/05/04

[Maven] Error instantiating builder ‘org.eclipse.m2e.core.maven2Builder’.

Problem
My eclipse had shut down unexpectedly. As I restart eclipse, and try to do maven clean.

The console show this error message
1
2
3
4
Errors occurred during the build.
Error instantiating builder org.eclipse.m2e.core.maven2Builder.
Plug-in org.eclipse.m2e.core was unable to load class org.eclipse.m2e.core.internal.builder.MavenBuilder.
An error occurred while automatically activating bundle org.eclipse.m2e.core (524).

Solution
Step 1. Shut down eclipse
Step 2. execute eclipse with -clean parameter, i.e. "eclipse.exe -clean"
Then the Maven is working fine.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building FMS :: Entity Classes 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ fms-entity ---
[INFO] Deleting D:\git\fms\fms-entity\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.229s
[INFO] Finished at: Mon May 04 17:42:59 CST 2015
[INFO] Final Memory: 5M/120M
[INFO] ------------------------------------------------------------------------


Reference
[1] http://stackoverflow.com/questions/25929458/building-workspace-has-encountered-an-error

2015/05/01

[閱讀筆記] 彼得林區學以致富

  1. 你未來的富裕不只是取決於你賺多少錢,還要看你如何善用這些錢來儲蓄與投資
  2. Isaac Newton 曾說:我可以計算天體的運動,但無法計算人的瘋狂
  3. 當你成為一家公司股東後,只有公司成功你才賺得到錢,但大部份公司無法成功,這就是買股票的風險,你都持有股票的公司最後可能一文不值。人們正是因為承擔這種風險而獲得豐厚報酬,如果選對公司的話
  4. 當政府要推動一項計畫時,他有四個獲得財源的選擇:徵稅、向銀行貸款、出售彩券或發行債券。 當公司需要錢,他可以向銀行借錢、銷售債券或發行股票
  5. 競爭是資本主義的關鍵,只要任何人都能自由地製造和更便宜的產品,企業就不敢奢望欺騙消費者而能逃過制裁。競爭讓公司戒慎恐懼,怕顧客被對手搶走
  6. 商業就像運動,常勝軍和成功的組織不會永遠保持第一。要達到頂尖地位極其困難,要長保第一更是難上加難
  7. 儲蓄和投資的第一個目標是趕上通貨膨脹。如果你只靠定存,你的錢就是在一架不斷往後退的跑步機上,以近幾年來看,你的投資必須賺3%以上才能趕上他倒退的速度
  8. 債券償還的日期越長,通貨膨脹在你收回借款前侵蝕金錢價值的風險就越高。這就是債券利率高於短期投資如定存單、儲蓄帳戶或貨幣市場的原因。因為投資人必須承擔較高的風險。
  9. 好的投資人和壞的投資人的差別往往不是聰明才智,而是紀律。你要有耐心和勇氣堅守股票,否則你就淪為一個平庸的投資人
  10. 人們永遠在尋找股市致勝的秘訣,然而這個祕訣近在眼前:買獲利佳的好公司股票,沒有好理由絕對不賣掉它。股價下跌不是賣股票的好理由
  11. 投資項目有很多種,如果可能的話,你應該投資股票。而且只要發行股票的公司營運保持良好,你應該緊抱這些股票,越久越好
  12. 記住,當股市重挫時,基金也會跟著虧損。不管是1929年的崩盤,或1972-1973年、1990年、2000年的崩盤都是如此
  13. 如果你是長期投資人,別理會債券基金和混合基金(同時投資股票還債券的基金),只買純股票基金。股票在20世紀美國的90年中,有80年超越債券。如果你不100%投資股市,長期來看你會少賺很多錢
  14. 經常更換基金划不來,你最好是挑選一家長期績效卓越的基金,然後長期守住他
  15. 基金的績效計算,必須減去手續費和管理費以後,才是你賺到的錢
  16. 投資並非精確的科學,不管多努力研究數字、了解公司過去的績效,你永遠無法確定他未來的表現。明日會發生的事永遠只是揣測,投資人能做的,是做有根據的揣測而不盲目,運用知識把風險降到最低
  17. 一堆投資人在研究交易模式,製作曲折起伏的圖形,試圖預測市場未來走向,然而實際上,他們該追蹤的其實是自己股票的公司獲利的情況
  18. 成功選股人的出發點:尋找未來多年盈餘可以持續成長的公司,因為如果獲利持續增加,股價註定會上漲
  19. 如果挑選多家公司,把他們的股價加起來,然後除以它們的盈餘,就可以得出一個平均本益比。在華爾街,人們用此方式計算道瓊工業指數、S&P 500指數的本益比,得出所謂的市場乘數,也就是平均本益比。其代表著人們願意以多高的價格買下多少盈餘的公司
  20. 當公司賺錢速度跟不上通膨速度,投資人就會開始恐慌,賣出股票。1970年代和1980年代的通貨膨脹時,股票與債券價格都大幅滑落
  21. 經濟衰退時,銷售軟性飲料、漢堡、藥品等民生必需品或平價產品的公司,可以安度衰退。銷售汽車、冰箱和房屋等高單價產品的公司,較難捱過衰退期間
  22. 當經濟太冷時,聯準會會做兩件事:一、降低銀行向政府借錢的利率,促使銀行降低向客戶收取的利率,讓人們負擔得起借更多錢來買房子和車子,於是經濟開始加溫。二、直接挹注資金到銀行體系,銀行有更多資金可以放款,導致利率降低。在某些情況,政府可以花更多錢來刺激經濟
  23. 如果經濟過熱,聯準會會提高利率、減少銀行體系裡的資金,導致貨幣供給萎縮。利率攀升,導致銀行貸款成本變高,許多消費者負擔不起,因而開始停止買車,經濟開始冷卻,企業生意減少、員工失業,商店變得冷清,不得不降價吸引顧客
  24. 當股價從上一個高峰下跌10%,就稱之為修正 (correction)。20世紀共有出現53次修正,平均兩年就有一次。當股價下跌超過25%就稱為熊市 (空頭市場)。在53次修正中,有15次變成熊市,平均每六年一次
  25. 投資股票的大忌之一是頻繁進出股票或股票共同基金,期待避開修正的來臨。另一個錯誤是,在你投資股票前坐擁現金等待即將來臨的修正。人們往往因為嘗試預測市場時機以逃避空頭市場,而錯失把握多頭市場的機會
  26. 空頭市場的問題有個簡單的解決辦法,擬定一個買進股票或股票共同基金的時間表,每個月、每四個月或每六個月投資一次,這會省掉你操心多頭或空頭市場的問題
  27. 巴菲特遵守一個簡單的策略:買進好公司的股票,並長久抱住他們。方法非常無聊,但成果卻一點也不無聊,如果你跟著巴菲特從四十年生涯的開始投資一萬美元,現在已變成八千萬美元


2015/04/30

2015/04 Travel

九份


無耳茶壺山


不厭亭


黃金瀑布


陰陽海


大肚美人山



2015/04/29

How to sort list of Java object with multiple fields

Problem
Assume I have a Java bean which named Fms432fa
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@Data
public class Fms432fa implements Serializable {
    // default serial version id, required for serializable classes.
    private static final long serialVersionUID = 1L;

    private BigDecimal befalc1;
    private String accyr;
    private String dataType;
    private String rptNo;
    private BigDecimal alc1;
    private BigDecimal alc2;
    private BigDecimal alc3;
    private BigDecimal alc4;
    private BigDecimal alc5;
    private BigDecimal alc6;
    private BigDecimal alc7;
    private BigDecimal alc8;
    private BigDecimal alc9;
    private BigDecimal alc10;
    private BigDecimal alc11;
    private BigDecimal alc12;
    private String userid;
    private String updDateTime;

    /** {@inheritDoc} */
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

}

If I have a List of Fms432fa, and I would like to sort it by accyr, dataType and rptNo. How to do it?

Solution
Utilize Google Guava to fulfill this sorting requirement
1
2
3
4
5
6
7
8
        Collections.sort(fms432fas, new Comparator<Fms432fa>() {
            @Override
            public int compare(Fms432fa o1, Fms432fa o2) {
                return ComparisonChain.start().compare(o1.getAccyr(), o2.getAccyr())
                        .compare(o1.getDataType(), o2.getDataType())
                        .compare(o1.getRptNo(), o2.getRptNo()).result();
            }
        });


Reference
[1] http://blog.projectnibble.org/2013/06/21/ways-to-sort-lists-of-objects-in-java-based-on-multiple-fields/ 

2015/04/24

org.springframework.orm.jpa.JpaSystemException: null id generated for:class {0}

Problem
Here is my table schema with composite key

Owning to this table has composite key, so it will have primary key class and entity class.

 primary key class
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package gov.nta.entity.dbm;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * The primary key class for the DBM400FA database table.
 * 
 */
@Embeddable
public class Dbm400faPK implements Serializable {
    // default serial version id, required for serializable classes.
    private static final long serialVersionUID = 1L;

    @Column(name = "CONTRACT_YEAR", unique = true, nullable = false, length = 4)
    private String contractYear;

    @Column(name = "BANK_SEQ_NO", unique = true, nullable = false, precision = 10)
    private long bankSeqNo;

    @Temporal(TemporalType.DATE)
    @Column(name = "CONTRACT_DATE", unique = true, nullable = false)
    private java.util.Date contractDate;

    public Dbm400faPK() {
    }

    public String getContractYear() {
        return this.contractYear;
    }

    public void setContractYear(String contractYear) {
        this.contractYear = contractYear;
    }

    public long getBankSeqNo() {
        return this.bankSeqNo;
    }

    public void setBankSeqNo(long bankSeqNo) {
        this.bankSeqNo = bankSeqNo;
    }

    public java.util.Date getContractDate() {
        return this.contractDate;
    }

    public void setContractDate(java.util.Date contractDate) {
        this.contractDate = contractDate;
    }

    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (!(other instanceof Dbm400faPK)) {
            return false;
        }
        Dbm400faPK castOther = (Dbm400faPK) other;
        return this.contractYear.equals(castOther.contractYear)
                && (this.bankSeqNo == castOther.bankSeqNo)
                && this.contractDate.equals(castOther.contractDate);
    }

    public int hashCode() {
        final int prime = 31;
        int hash = 17;
        hash = hash * prime + this.contractYear.hashCode();
        hash = hash * prime + ((int) (this.bankSeqNo ^ (this.bankSeqNo >>> 32)));
        hash = hash * prime + this.contractDate.hashCode();

        return hash;
    }
}


entity class
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package gov.nta.entity.dbm;

import java.io.Serializable;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;


/**
 * The persistent class for the DBM400FA database table.
 * 
 */
@Entity
@Table(name="DBM400FA")
@NamedQuery(name="Dbm400fa.findAll", query="SELECT d FROM Dbm400fa d")
public class Dbm400fa implements Serializable {
 private static final long serialVersionUID = 1L;

 @EmbeddedId
 private Dbm400faPK id;

 @Column(name="BORROW_AMOUNT", precision=20, scale=4)
 private BigDecimal borrowAmount;

 @Column(name="CONTRACT_AMOUNT", precision=20, scale=4)
 private BigDecimal contractAmount;

 @Temporal(TemporalType.DATE)
 @Column(name="CREATE_DATE")
 private Date createDate;

 @Column(name="DAILY_LIMIT", precision=20, scale=4)
 private BigDecimal dailyLimit;

 @Column(name="REVIEW_ID", length=20)
 private String reviewId;

 @Column(name="REVIEW_STATUS", length=1)
 private String reviewStatus;

 @Column(name="SOURCE_ID", precision=10)
 private BigDecimal sourceId;

 @Column(name="TOTAL_LIMIT", precision=20, scale=4)
 private BigDecimal totalLimit;

 @Temporal(TemporalType.DATE)
 @Column(name="UPDATE_DATE")
 private Date updateDate;

 @Column(name="USER_ID", length=20)
 private String userId;

 public Dbm400fa() {
 }

 public Dbm400faPK getId() {
  return this.id;
 }

 public void setId(Dbm400faPK id) {
  this.id = id;
 }

 public BigDecimal getBorrowAmount() {
  return this.borrowAmount;
 }

 public void setBorrowAmount(BigDecimal borrowAmount) {
  this.borrowAmount = borrowAmount;
 }

 public BigDecimal getContractAmount() {
  return this.contractAmount;
 }

 public void setContractAmount(BigDecimal contractAmount) {
  this.contractAmount = contractAmount;
 }

 public Date getCreateDate() {
  return this.createDate;
 }

 public void setCreateDate(Date createDate) {
  this.createDate = createDate;
 }

 public BigDecimal getDailyLimit() {
  return this.dailyLimit;
 }

 public void setDailyLimit(BigDecimal dailyLimit) {
  this.dailyLimit = dailyLimit;
 }

 public String getReviewId() {
  return this.reviewId;
 }

 public void setReviewId(String reviewId) {
  this.reviewId = reviewId;
 }

 public String getReviewStatus() {
  return this.reviewStatus;
 }

 public void setReviewStatus(String reviewStatus) {
  this.reviewStatus = reviewStatus;
 }

 public BigDecimal getSourceId() {
  return this.sourceId;
 }

 public void setSourceId(BigDecimal sourceId) {
  this.sourceId = sourceId;
 }

 public BigDecimal getTotalLimit() {
  return this.totalLimit;
 }

 public void setTotalLimit(BigDecimal totalLimit) {
  this.totalLimit = totalLimit;
 }

 public Date getUpdateDate() {
  return this.updateDate;
 }

 public void setUpdateDate(Date updateDate) {
  this.updateDate = updateDate;
 }

 public String getUserId() {
  return this.userId;
 }

 public void setUserId(String userId) {
  this.userId = userId;
 }

}


But as I execute this query SQL statement by JPA:
1
2
3
4
5
SELECT *
FROM DBM400FA
WHERE CONTRACT_YEAR = :contractYr
  AND BANK_SEQ_NO = :bankSeqNo
  AND to_char(contract_date,'yyyyMMdd') = :contractDate + '19110000'

It will throw exception:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
org.springframework.orm.jpa.JpaSystemException: null id generated for:class gov.nta.entity.dbm.Dbm400fa; nested exception is org.hibernate.id.IdentifierGenerationException: null id generated for:class gov.nta.entity.dbm.Dbm400fa
 at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:244) ~[spring-orm-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:155) ~[spring-orm-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417) ~[spring-orm-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59) ~[spring-tx-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) ~[spring-tx-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147) ~[spring-tx-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:105) ~[spring-data-jpa-1.5.2.RELEASE.jar:na]
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.0.3.RELEASE.jar:4.0.3.RELEASE]
 at com.sun.proxy.$Proxy112.saveAndFlush(Unknown Source) ~[$Proxy112.class:na]
 at gov.nta.dbm.service.DbmBankContractService.saveDbm400faFromDbm400f1(DbmBankContractService.java:312) ~[classes/:na]


Solution
You should use @IdClass instead of @EmbeddedId

Id class
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gov.nta.entity.dbm;

import java.io.Serializable;

/**
 * The primary key class for the DBM400FA database table.
 * 
 */
public class Dbm400faPK implements Serializable {
    // default serial version id, required for serializable classes.
    private static final long serialVersionUID = 1L;

    private String contractYear;

    private long bankSeqNo;

    private java.util.Date contractDate;

    public Dbm400faPK() {
    }

    public String getContractYear() {
        return this.contractYear;
    }

    public void setContractYear(String contractYear) {
        this.contractYear = contractYear;
    }

    public long getBankSeqNo() {
        return this.bankSeqNo;
    }

    public void setBankSeqNo(long bankSeqNo) {
        this.bankSeqNo = bankSeqNo;
    }

    public java.util.Date getContractDate() {
        return this.contractDate;
    }

    public void setContractDate(java.util.Date contractDate) {
        this.contractDate = contractDate;
    }

    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (!(other instanceof Dbm400faPK)) {
            return false;
        }
        Dbm400faPK castOther = (Dbm400faPK) other;
        return this.contractYear.equals(castOther.contractYear)
                && (this.bankSeqNo == castOther.bankSeqNo)
                && this.contractDate.equals(castOther.contractDate);
    }

    public int hashCode() {
        final int prime = 31;
        int hash = 17;
        hash = hash * prime + this.contractYear.hashCode();
        hash = hash * prime + ((int) (this.bankSeqNo ^ (this.bankSeqNo >>> 32)));
        hash = hash * prime + this.contractDate.hashCode();

        return hash;
    }
}


entity class with Id class
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package gov.nta.entity.dbm;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * The persistent class for the DBM400FA database table.
 * 
 */
@Entity
@Table(name = "DBM400FA")
@IdClass(Dbm400faPK.class)
@NamedQuery(name = "Dbm400fa.findAll", query = "SELECT d FROM Dbm400fa d")
public class Dbm400fa implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "CONTRACT_YEAR", unique = true, nullable = false, length = 4)
    private String contractYear;

    @Id
    @Column(name = "BANK_SEQ_NO", unique = true, nullable = false, precision = 10)
    private long bankSeqNo;

    @Id
    @Temporal(TemporalType.DATE)
    @Column(name = "CONTRACT_DATE", unique = true, nullable = false)
    private java.util.Date contractDate;

    @Column(name = "BORROW_AMOUNT", precision = 20, scale = 4)
    private BigDecimal borrowAmount;

    @Column(name = "CONTRACT_AMOUNT", precision = 20, scale = 4)
    private BigDecimal contractAmount;

    @Temporal(TemporalType.DATE)
    @Column(name = "CREATE_DATE")
    private Date createDate;

    @Column(name = "DAILY_LIMIT", precision = 20, scale = 4)
    private BigDecimal dailyLimit;

    @Column(name = "REVIEW_ID", length = 20)
    private String reviewId;

    @Column(name = "REVIEW_STATUS", length = 1)
    private String reviewStatus;

    @Column(name = "SOURCE_ID", precision = 10)
    private BigDecimal sourceId;

    @Column(name = "TOTAL_LIMIT", precision = 20, scale = 4)
    private BigDecimal totalLimit;

    @Temporal(TemporalType.DATE)
    @Column(name = "UPDATE_DATE")
    private Date updateDate;

    @Column(name = "USER_ID", length = 20)
    private String userId;

    public Dbm400fa() {
    }

    public BigDecimal getBorrowAmount() {
        return this.borrowAmount;
    }

    public void setBorrowAmount(BigDecimal borrowAmount) {
        this.borrowAmount = borrowAmount;
    }

    public BigDecimal getContractAmount() {
        return this.contractAmount;
    }

    public void setContractAmount(BigDecimal contractAmount) {
        this.contractAmount = contractAmount;
    }

    public Date getCreateDate() {
        return this.createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public BigDecimal getDailyLimit() {
        return this.dailyLimit;
    }

    public void setDailyLimit(BigDecimal dailyLimit) {
        this.dailyLimit = dailyLimit;
    }

    public String getReviewId() {
        return this.reviewId;
    }

    public void setReviewId(String reviewId) {
        this.reviewId = reviewId;
    }

    public String getReviewStatus() {
        return this.reviewStatus;
    }

    public void setReviewStatus(String reviewStatus) {
        this.reviewStatus = reviewStatus;
    }

    public BigDecimal getSourceId() {
        return this.sourceId;
    }

    public void setSourceId(BigDecimal sourceId) {
        this.sourceId = sourceId;
    }

    public BigDecimal getTotalLimit() {
        return this.totalLimit;
    }

    public void setTotalLimit(BigDecimal totalLimit) {
        this.totalLimit = totalLimit;
    }

    public Date getUpdateDate() {
        return this.updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String getUserId() {
        return this.userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getContractYear() {
        return contractYear;
    }

    public void setContractYear(String contractYear) {
        this.contractYear = contractYear;
    }

    public long getBankSeqNo() {
        return bankSeqNo;
    }

    public void setBankSeqNo(long bankSeqNo) {
        this.bankSeqNo = bankSeqNo;
    }

    public java.util.Date getContractDate() {
        return contractDate;
    }

    public void setContractDate(java.util.Date contractDate) {
        this.contractDate = contractDate;
    }

    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

}


Reference
[1] http://www.objectdb.com/java/jpa/entity/id