Jin Kwon (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDdkOTI1Mjgw...
) / Improvement (
https://hibernate.atlassian.net/browse/HHH-15596?atlOrigin=eyJpIjoiZDdkOT...
) HHH-15596 (
https://hibernate.atlassian.net/browse/HHH-15596?atlOrigin=eyJpIjoiZDdkOT...
) Invalid column alias on @JoinFormula (
https://hibernate.atlassian.net/browse/HHH-15596?atlOrigin=eyJpIjoiZDdkOT...
)
Issue Type: Improvement Affects Versions: 5.6.11 Assignee: Unassigned Components:
hibernate-core Created: 11/Oct/2022 20:07 PM Environment: Running
`/Users/onacit/gitcl/bitbucket.wemakeprice.com/etc/spring-data-jpa-base8-wmp-deal/mvnw`...
Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home:
/Users/onacit/.m2/wrapper/dists/apache-maven-3.8.5-bin/5i5jha092a3i37g0paqnfr15e0/apache-maven-3.8.5
Java version: 17.0.4.1, vendor: Eclipse Adoptium, runtime:
/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
Default locale: en_KR, platform encoding: UTF-8
OS name: "mac os x", version: "12.5", arch: "aarch64",
family: "mac" Priority: Minor Reporter: Jin Kwon (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
I need to query look like this.
select
psaer.excel_row_seq as excel_ro1_156_0_,
psaer.excel_row_no as excel_ro2_156_0_,
psaer.prod_info_batch_excel_seq as prod_inf3_156_0_,
psaer.prod_no as prod_no4_156_0_,
psaer.row_msg as row_msg5_156_0_,
psaer.row_status as row_stat6_156_0_,
IF(psaer.prod_no REGEXP '[^[:digit:]]+', NULL, psaer.prod_no) as formula88_0_
from
prod_status_active_excel_row psaer
;
When I do with following code,
@Nullable
@Valid
@NotFound(action = NotFoundAction.IGNORE) // -> EAGER!
// @JoinFormula("CASE "
// + " WHEN " +
MappedProdStatusActiveExcelRow.COLUMN_NAME_PROD_NO + " REGEXP
'[^[:digit:]]+'"
// + " THEN NULL"
// + " ELSE " +
MappedProdStatusActiveExcelRow.COLUMN_NAME_PROD_NO
// + " END")
@JoinFormula("IF("
+ MappedProdStatusActiveExcelRow.COLUMN_NAME_PROD_NO + " REGEXP
'[^[:digit:]]+'"
+ ", NULL"
+ ", " + MappedProdStatusActiveExcelRow.COLUMN_NAME_PROD_NO
+ ")")
@ManyToOne(optional = true, fetch = FetchType.LAZY)
// @JoinColumn(name = COLUMN_NAME_PROD_NO, nullable = true, insertable = false,
updatable = false,
// foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
@EqualsAndHashCode.Exclude
@ToString.Exclude
private Prod prod;
Hibernate seems generate sql look like this.
select
prodstatus0_.excel_row_seq as excel_ro1_156_0_,
prodstatus0_.excel_row_no as excel_ro2_156_0_,
prodstatus0_.prod_info_batch_excel_seq as prod_inf3_156_0_,
prodstatus0_.prod_no as prod_no4_156_0_,
prodstatus0_.row_msg as row_msg5_156_0_,
prodstatus0_.row_status as row_stat6_156_0_,
IF(prodstatus0_.`prod_no` prodstatus0_.REGEXP '[^[:digit:]]+',
NULL,
prodstatus0_.prod_no) as formula88_0_
from
prod_status_active_excel_row prodstatus0_
...
The column alias between IF(prodstatus0_.\`prod_no` and REGEX .. seems wrong.
What can I do for this? Thanks.
(
https://hibernate.atlassian.net/browse/HHH-15596#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15596#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100208- sha1:399748d )