-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-15102 Processing of annotation recognition in BasicFormatterImpl #4852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HHH-15102 Processing of annotation recognition in BasicFormatterImpl #4852
Conversation
beikov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Can you please also add some tests that verify a few sample statements are formatted correctly?
| if (lcToken.equals("-")) | ||
| { | ||
| String ttt; | ||
| do { | ||
| ttt = tokens.nextToken(); | ||
| token += ttt; | ||
| } | ||
| while (tokens.hasMoreTokens()); | ||
| lcToken = token; | ||
| misc(); | ||
| } | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem like your code distinguishes a simple minus sign - from a comment -- properly. The following should work though:
| if (lcToken.equals("-")) | |
| { | |
| String ttt; | |
| do { | |
| ttt = tokens.nextToken(); | |
| token += ttt; | |
| } | |
| while (tokens.hasMoreTokens()); | |
| lcToken = token; | |
| misc(); | |
| } | |
| break; | |
| String ttt; | |
| if ( tokens.hasMoreTokens() && ( ttt = tokens.nextToken() ).equals( "-" ) ) { | |
| // Comment | |
| token += "--"; | |
| while (tokens.hasMoreTokens()) { | |
| ttt = tokens.nextToken(); | |
| token += ttt; | |
| } | |
| lcToken = token; | |
| misc(); | |
| } | |
| else { | |
| misc(); | |
| } | |
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at the code you suggested,
token += "--";
I don't know if it's because of that.
The code -- is expressed as ---.
So when I turned to the original code, both the case of -- and - met the test.
|
When I tested the case of -, I found that it operated normally with my commitment. As a result of operating with the code you suggested, you can see that the code of -- is unnecessarily ---. I am attaching the SQL statement that I greeted. My test was conducted with the corresponding SQL. /* VoucherIssueTotalMapper.xml, list3 */SELECT
*
FROM
( SELECT
COUNT(*) OVER () AS RN_MAX,
a.*
FROM
( SELECT
ROW_NUMBER() OVER(
ORDER BY
a.USE_DATE DESC NULLS FIRST) AS listNum ,
a.STTUS sttusName ,
TO_CHAR(a.USE_DATE,
'YYYY-MM-DD HH24:MI:SS') occurDate ,
a.USE_IDX issueIdx ,
a.AFFILIATE_CODE affiliateCode ,
d.AFFILIATE_NAME affiliateName ,
d.EXCCLC_TYPE excclcType ,
CASE
WHEN d.EXCCLC_TYPE = '1' THEN '발행'
ELSE '사용'
END excclcTypeName ,
a.BNDUNT_TYPE bnduntType ,
(SELECT
CODE_NAME
FROM
VW_CODE x
WHERE
x.MST_ID = 'bnduntType'
AND x.CODE = a.BNDUNT_TYPE) bnduntTypeName ,
a.BNDUNT_CODE bnduntCode ,
(SELECT
CODE_NAME
FROM
VW_CODE x
WHERE
x.MST_ID = 'bnduntCode'
AND x.CODE = a.BNDUNT_CODE) bnduntCodeName ,
a.VOUCHER_CODE voucherCode ,
e.VOUCHER_NAME voucherName ,
f.EVENT_NAME eventName ,
a.USE_IDX approvalNo ,
f.VOUCHER_PRICE voucherPrice ,
a.BARCODE_NO barcodeNo ,
UF_DECRYPT(f.RECV_NO) recvNo ,
a.BEFORE_BALANCE beforeBalance ,
a.STTUS sttus ,
CASE
WHEN a.BNDUNT_TYPE = 'BP0000'
AND a.BNDUNT_CODE = 'BP0101' THEN NVL(PDT.ITEM_CNT,
1)
ELSE 1
END * (case
when a.sttus = '50'
or a.sttus = '60' then a.USE_PRICE
else -a.USE_PRICE
end) usePrice ,
a.AFTER_BALANCE afterBalance ,
NVL(c.ORDER_NO,
b.ORDER_NO) orderNo ,
x.CHAINSTORE_NAME AS useStoreName ,
a.STORE_CODE useStoreCode ,
f.ISSUE_TYPE issueType ,
(SELECT
CODE_NAME
FROM
CODE_DETAIL x
WHERE
f.ISSUE_TYPE = x.CODE
AND x.MST_CODE = 'ISSUE_TYPE') issueTypeName ,
CASE
WHEN a.FIRST_CNT > 0 THEN 'Y'
ELSE 'N'
END firstYn ,
PDT.PLUCD1 AS plucd1 ,
PDT.ITEM_NM AS itemNm --,
f.VOUCHER_PRICE AS hyhnMaega ,
(CASE
WHEN a.BNDUNT_CODE IN ('TP2000',
'TP2100',
'TP2200',
'TP2300') THEN (CASE
WHEN vpp.VAL_TYPE='1' THEN f.VOUCHER_PRICE - vpp.VAL
ELSE f.VOUCHER_PRICE - (f.VOUCHER_PRICE * vpp.VAL/100)
END)
ELSE f.VOUCHER_PRICE
END) AS hyhnMaega ,
f.FIRST_YN ,
c.FIRST_CNT firstCnt ,
(SELECT
AFFILIATE_NAME
FROM
AFFILIATE
WHERE
AFFILIATE_CODE = a.USE_AFFILIATE_CODE) AS useAffiliateCode ,
a.FIRST_CNT firstUseCnt ,
substr(f.barcode_no,
0,
3) preFix
FROM
( SELECT
*
FROM
VOUCHER_USE_LIST a
WHERE
1=1
AND a.STTUS IN (
'50', '51', '95', '60', '90'
)
AND a.AFFILIATE_CODE IN (
SELECT
AFFILIATE_CODE
FROM
AFFILIATE
WHERE
AFFILIATE_CODE = :1
OR UPPER_AFFILIATE_CODE = :2
)
) a
JOIN
ISSUE_DTL c
on a.BARCODE_NO = c.BARCODE_NO
JOIN
ISSUE_MST b
on b.ISSUE_IDX = c.ISSUE_IDX
AND b.STTUS='40'
JOIN
AFFILIATE d
on a.AFFILIATE_CODE = d.AFFILIATE_CODE
JOIN
VOUCHER e
on a.VOUCHER_CODE = e.VOUCHER_CODE
JOIN
PIN_NUMBER f
on a.BARCODE_NO = f.BARCODE_NO
LEFT JOIN
(
SELECT
A.USE_IDX,
MAX(B.PLUCD1) AS PLUCD1 ,
MAX(B.ITEM_NM) AS ITEM_NM ,
A.BARCODE_NO ,
MAX(B.HYUN_MAEGA) AS HYUN_MAEGA ,
SUM(B.ITEM_CNT) AS ITEM_CNT
FROM
VOUCHER_USE_LIST A,
( SELECT
BARCODE_NO ,
USE_IDX,
PLUCD1 ,
ITEM_NM ,
HYUN_MAEGA ,
ITEM_CNT
FROM
VOUCHER_USE_PRODUCT
GROUP BY
BARCODE_NO,
USE_IDX,
PLUCD1,
ITEM_NM ,
HYUN_MAEGA ,
ITEM_CNT ) B,
VOUCHER_PRODUCT C
WHERE
A.BARCODE_NO = B.BARCODE_NO
AND A.USE_IDX = B.USE_IDX
AND B.PLUCD1 = C.PLUCD1
AND A.VOUCHER_CODE = C.VOUCHER_CODE
GROUP BY
A.USE_IDX,
A.BARCODE_NO ) PDT
ON (PDT.USE_IDX = CASE
WHEN a.STTUS = 51 THEN a.CANCL_USE_IDX
ELSE a.USE_IDX
END
AND a.BARCODE_NO = PDT.BARCODE_NO)
LEFT JOIN
CHAINSTORE x
ON a.STORE_CODE = x.CHAINSTORE_CODE
LEFT OUTER JOIN
VOUCHER_PRICE_POLICY vpp
ON vpp.VOUCHER_CODE = a.VOUCHER_CODE
WHERE
1=1
AND d.AFFILIATE_TYPE = :3
AND d.AFFILIATE_NAME LIKE '%'||:4 ||'%'
AND b.STTUS = 40
AND b.ISSUE_DATE BETWEEN TO_DATE(:5 ||'000000','YYYY-MM-DDHH24MISS') AND TO_DATE(:6 ||'235959','YYYY-MM-DDHH24MISS')
) a
) a |
|
Thanks. Superseded by #9336. |


https://hibernate.atlassian.net/browse/HHH-15102
I use making SQL statements pretty in BasicFormatterImpl.
However, if there is a comma behind the annotation, the column behind the annotation is sent to the next line to recognize the column that should not be recognized.
So I customized the class.
The result was successful. I hope that the full request will be reflected based on the successful results.
Below is the situation I went through.

The left side is raw SQL, and the right side is the result of formatting using the class. You can see that the column behind the annotation went to the next line.
Normal results after processing it.
