[
https://issues.apache.org/jira/browse/CAY-2863?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Nikita Timofeev reassigned CAY-2863:
------------------------------------
Assignee: Nikita Timofeev
> DbEntity qualifiers are no longer applied to JOIN conditions
> ------------------------------------------------------------
>
> Key: CAY-2863
> URL: https://issues.apache.org/jira/browse/CAY-2863
> Project: Cayenne
> Issue Type: Bug
> Components: Core Library
> Affects Versions: 4.0.3, 4.1.1, 4.2.1, 5.0-M1
> Reporter: Jurgen Doll
> Assignee: Nikita Timofeev
> Priority: Major
> Labels: Regression
> Fix For: 4.2.3, 5.0-M2
>
>
> This is a regression from 3.1.3
> DbEntity qualifiers used to be applied to JOIN conditions but have now moved
> to the WHERE clause. This results in queries returning no results when there
> are OR conditions in the WHERE part that could satisfy the query.
> Here's a possible test case for DefaultSelectTranslatorIT.java
> {code:java}
> @Test
> public void testDbEntityQualifier_JoinQuery() throws Exception {
>
> final DbEntity entity =
> context.getEntityResolver().getDbEntity("ARTIST");
> entity.setQualifier(ExpressionFactory.exp("ARTIST_NAME = 'Should be
> on JOIN condition and not WHERE'"));
> ObjectSelect<Painting> q = ObjectSelect.query(Painting.class)
> .where
> (
> Painting.TO_ARTIST.dot(Artist.DATE_OF_BIRTH).eq(new
> java.sql.Date(1,0,1))
> .orExp( Painting.TO_GALLERY.dot( Gallery.GALLERY_NAME ).like(
> "G%" ) )
> );
> // If the DbEntity qualifier is set on the WHERE condition then the
> OR expression will fail to find matches
> SelectTranslator transl = new DefaultSelectTranslator(q,
> dataNode.getAdapter(), dataNode.getEntityResolver());
> try {
> String generatedSql = transl.getSql();
> int whereNdx = generatedSql.indexOf(" WHERE ");
> int joinNdx = generatedSql.indexOf(" JOIN ARTIST ");
> assertTrue(generatedSql.substring(joinNdx,
> whereNdx).indexOf("ARTIST_NAME") > 0); // Should be in JOIN condition
> assertTrue(generatedSql.indexOf("ARTIST_NAME", whereNdx) < 0); //
> Should not be part of WHERE
> }
> finally {
> entity.setQualifier(null);
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)