"in elements" generated subquery table name not corrected translated on "insert into ... select" queries

Description

The following hql:
--------------------------------------------------------------------------------------------------------------------
sb.append( " insert into ValorIndicador ( indicador," );
sb.append( " tipoValor ) " );
sb.append( " select vi.indicador, " );
sb.append( " vi.tipoValor ");
sb.append( " from ValorIndicador vi, PerfilIndicador pi " );
sb.append( " where 1 = 1 " );
sb.append( " and vi.indicador = pi.indicador " );
sb.append( " and vi.tipoValor in elements( pi.cenarios ) " );
-------------------------------------------------------------------------------------------------------------------
after translation generates the following WRONG sql:
------------------------------------------------------------------------------------------------------------------- insert
into
VALORINDICADOR
( indicador, tipovalor ) select
valorindic0_.indicador as col_0_0_,
valorindic0_.tipovalor as col_1_0_
from
VALORINDICADOR valorindic0_,
PERFILINDICADOR perfilindi1_
where
1=1
and valorindic0_.indicador=perfilindi1_.indicador
and (
valorindic0_.tipovalor in (
select
cenarios2_.cenario
from
cenarios cenarios2_
where
PERFILINDICADOR.id=cenarios2_.perfilindicador_id
)
)
-------------------------------------------------------------------------------------------------------------------
while without the "insert into" statement :
------------------------------------------------------------------------------------------------------------------- sb.append( " select vi.indicador, " );
sb.append( " vi.tipoValor ");
sb.append( " from ValorIndicador vi, PerfilIndicador pi " );
sb.append( " where 1 = 1 " );
sb.append( " and vi.indicador = pi.indicador " );
sb.append( " and vi.tipoValor in elements( pi.cenarios ) " );
-------------------------------------------------------------------------------------------------------------------
it translates to the CORRECT sql:
------------------------------------------------------------------------------------------------------------------- select
valorindic0_.indicador as col_0_0_,
valorindic0_.tipovalor as col_1_0_
from
VALORINDICADOR valorindic0_,
PERFILINDICADOR perfilindi1_
where
1=1
and valorindic0_.indicador=perfilindi1_.indicador
and (
valorindic0_.tipovalor in (
select
cenarios2_.cenario
from
cenarios cenarios2_
where
perfilindi1_.id=cenarios2_.perfilindicador_id
)
)
-------------------------------------------------------------------------------------------------------------------
Note that in the first generated sql, the table instance name of the "in elements" subquery is wrong. The entity name (PERFILINDICADOR) is used instead of the instance name (perfilindi1_).

In the second generated sql this problem doesn't occurs.

Environment

Windows XP SP2
latest Java 1.4
XML mapping
Derby 10.4.1.3

Activity

Show:
Brett Meyer
April 7, 2014, 5:41 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Brett Meyer
July 8, 2014, 3:10 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Rejected

Assignee

Unassigned

Reporter

Bruno Mayerle Leite

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Blocker