[hibernate-dev] When is Dialect.requiresCastingOfParametersInSelectClause applied?

Mark Rotteveel mark at lawinegevaar.nl
Mon Jan 30 12:00:57 EST 2017


After a hiatus of 6 months, I have gone back to my PR for 
improving/replacing the Firebird dialect. I am running into a number of 
test failures which I am working through to see if they are relevant or not.

One of the test failures I am looking at is 
org.hibernate.jpa.test.criteria.basic.ConcatTest.testSelectCaseWithConcat

Firebird is rather picky about parameters occurring in the 
select-clause, and they will almost always need to be cast to the 
necessary type (and lengths). This tests seems to generate the following 
query:

     select
         case
             when concattest0_.id is not null then (?||?)
             else 'Empty'
         end as col_0_0_,
         trim(both ' '
     from
         (?||?)) as col_1_0_
     from
         TEST_ENTITY concattest0_

I have implemented Dialect#requiresCastingOfParametersInSelectClause() 
to return true, but unfortunately for this specific test it has no effect.

The absolute minimum SQL necessary for this to work (with some caveats) is:

     select
         case
             when 1 = 1 then (?||?)
             else 'Empty'
         end as col_0_0_,
         trim(both ' '
     from
         (cast(? as varchar(256))|| cast(? as varchar(256)))) as col_1_0_
     from
         TEST_ENTITY concattest0_

And preferably the (?||?) in the case should have an explicit cast for 
each parameter as well, as otherwise each parameter is limited to 5 
characters each (setting longer values will lead to a truncation exception).

Is this something that is fixable, and if so how? Or is this one of 
those things where you just have to say 'aw, too bad, let it go' (or, 
maybe: do it later if it is really necessary)?

With this specific failure out of the way: what is the general rule of 
thumb of handling test failures in hibernate_core for a lesser-known 
dialect?

I currently have 257 test failures (and 512 ignored) with Firebird and 
my new dialect. I might add that some failures seem to be generic (eg 
DriverManagerRegistrationTest, StandardRefCursorSupportTest, 
NoCdiAvailableTest, XmlAccessTest, FetchProfileTest, IndexTest and some 
others).
--
Mark Rotteveel


More information about the hibernate-dev mailing list