Hibernate version: 2.1.6
Name and version of the database you are using:Currently v7.10. DB2 v8 is about 1 year away.
Question: Using Criteria based queries, what is the best way to handle, at an application level, the shifting collating sequence in DB2 as it varies between versions?
I have developed an application that will select based on alphanumeric ranges and values (pretty straightforward), but there is a distinct difference in the resultset being returned between DB2 versions.
What is the "best practice" with Hibernate to accomodate this shift?
Also worth noting, the Java Comparator implementation for String object values may differ with a given DB2 collating sequence, and as such (in my application) form validation (such as with Struts) can become problematic as you are coding custom Comparator's to override the Java implementation to accomodate the DB2 implementation.
Example:
Java: 0 > A is false
DB2 v7.10: 0 > A is true
Java: Order is [0-9] then [A-Z]
DB2 v7.10: Order is [A-Z] then [0-9]
Below is an excerpt of the DB2 collating sequence details relevant to my question. Hopefully someone can offer some insight on how best to develop a Hibernate based query application to handle this shift.
Is this a matter of utilizing different dialects for DB2?
How does Hibernate handle the differences in versions without altering how an application returns results?
Or, is this just "the way it is" and however the DB2 implementation defines the collating sequence is how it is meant to be interpretted and any alteration to that interpretation requires an application change/update to accomodate a give user's desire view of the results?
Hope that makes sense, and thanks ahead of time for any replies! :)
****************************************************EXCERPT*****************************************************
Below is an article concerning DB2 version 8. This is demonstrating the collating sequence of differences between Version 7 (EBCDIC) and Version 8 (Unicode).
After the article is information labeled 2.3.2.3 / 2.3.2.1 and this is IBM's explanation of Unicode, EBCDIC and ASCII.
Abstract Unicode sorting sequence is different than EBCDIC sorting sequence Content The collation sequence for Unicode is different than the sequence used by EBCDIC. In Unicode, numeric characters are sorted before alphabetic characters. In EBCDIC, alphabetic characters are sorted before numeric characters. Your queries might return results in a different order than in DB2 Version 7. GROUP BY, range predicates such as BETWEEN, and functions like MIN and MAX might return different answer sets than those returned in Version 7.
Example: Assume that the NAME column in SYSIBM.SYSTABLES contains the following values: TEST1, TEST2, TEST3, TESTA, TESTB, TESTC. In Version 7 or Version 8 compatibility mode, you issue the following SQL query:
SELECT NAME FROM SYSIBM.SYSTABLES
ORDER BY NAME
DB2
|