Skip to content
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

Inability to set alias for binding literal value #1937

Open
Drezir opened this issue Sep 26, 2024 · 2 comments
Open

Inability to set alias for binding literal value #1937

Drezir opened this issue Sep 26, 2024 · 2 comments
Labels
component: core kind: bug worth: high Implementing this has a high worth

Comments

@Drezir
Copy link

Drezir commented Sep 26, 2024

        var select = resultRawCriteriaBuilder
                .from(ObjCommunication.class, "com")
                .bind("type").select("'" + EntityType.COMMUNICATION + "'", "type")
                .bind("id").select("com.id")
                .bind("itemCreateDate").select("com.communicationBeginDate");

This generates this query (among other unions)

 from (select top 100 percent 'COMMUNICATION', oc1_0.id, oc1_0.communication_begin_date
            from obj_communication oc1_0
            where oc1_0.partner_code = ?
            order by oc1_0.communication_begin_date desc) grp_0_
      union

Hibernate generates select * from grp_0_.* which is wrong, there has to be an alias

But SQL server fails on
No column name was specified for column 1 of 'grp_0_'.

And I have no option how to force an alias to 'COMMUNICATION' literal column.

Hibernate version 6.5.3.Final
Blaze BOM version 1.6.12

@beikov
Copy link
Member

beikov commented Oct 7, 2024

Hi and sorry it took so long for me to respond. This looks like a bug in Hibernate ORM, but to be able to look into it more deeply, I'd need a reproducer. Could you please try to create one e.g. based on one of our quickstarts?

I think you could workaround this in the meantime by using the internal alias function.

@beikov beikov added kind: bug component: core worth: high Implementing this has a high worth labels Oct 7, 2024
@Drezir
Copy link
Author

Drezir commented Oct 8, 2024

Hi and sorry it took so long for me to respond. This looks like a bug in Hibernate ORM, but to be able to look into it more deeply, I'd need a reproducer. Could you please try to create one e.g. based on one of our quickstarts?

I think you could workaround this in the meantime by using the internal alias function.

I have tried ALIAS function, It has not worked. I will try to prepare example but I do not know when.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core kind: bug worth: high Implementing this has a high worth
Projects
None yet
Development

No branches or pull requests

2 participants