blaze-persistence icon indicating copy to clipboard operation
blaze-persistence copied to clipboard

Inability to set alias for binding literal value

Open Drezir opened this issue 1 year ago • 2 comments

        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

Drezir avatar Sep 26 '24 19:09 Drezir

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 avatar Oct 07 '24 08:10 beikov

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.

Drezir avatar Oct 08 '24 11:10 Drezir