Full disclosure - I know SQL but not Hibernate so view any suggestions in this light.
I'm pretty sure UPPER is ANSI standard SQL, but LTRIM and RTRIM aren't, so does replacing ltrim and rterim with a single TRIM work?
Also, a couple of (really) ignorant questions about Hibernate:
When doing the setParameter don't you need to specify the datatype?
countOpCodeQry.setParameter( "newOpCode", newOpCode, Hibernate.INTEGER );
instead of
countOpCodeQry.setParameter( "newOpCode", newOpCode );
Also do you need to worry about using native DB2, the Hibernate Documentation seems to indicate the syntax you have used supports native SQL.
http://www.hibernate.org/hib_docs/v3/reference/en/html/querysql.html The concern I have is the way you are passing in a bind variable value.
The examlples I have looked at suggest using
countOpCodeQry.setInteger( "newOpCode", newOpCode );
for an Int or
countOpCodeQry.setString( "newOpCode", newOpCode );
for a
string.