Jin Kwon (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiODQwNzU2MGI4...
) / Improvement (
https://hibernate.atlassian.net/browse/HHH-15596?atlOrigin=eyJpIjoiODQwNz...
) HHH-15596 (
https://hibernate.atlassian.net/browse/HHH-15596?atlOrigin=eyJpIjoiODQwNz...
) Invalid column alias on @JoinFormula (
https://hibernate.atlassian.net/browse/HHH-15596?atlOrigin=eyJpIjoiODQwNz...
)
Change By: Jin Kwon (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
I need to query look like this.
{noformat}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
;
{noformat}
When I do with following code,
{noformat} @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;{noformat}
Hibernate seems generate sql look like this.
{noformat}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:]]+', -- column
alias?
NULL,
prodstatus0_.prod_no) as formula88_0_
from
prod_status_active_excel_row prodstatus0_
...{noformat}
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 )