Hibernate version:2.1.8
Database: Oracle 10g
Application Server: WebLogic 10.3
My application is using Hibernate-2.1.8 to access an Oracle 10g database. Application is running in WebLogic-10.3. Hibernate uses a WebLogic datasource. The datasource uses the Oracle JDBC driver from Oracle which is part of WebLogic-10.3 distribution.
In this environment Hibernate does not use prepared statements. The JDBC performance is bad.
I tested the same application in JBoss-4.2 with the same database, In JBoss prepared statements are used. Both server uses the same JDBC driver form Oracle. I added two SQL statements which Hibernate generated from the same HQL source in WebLogic and JBoss in the end of this posting.
Why Hibernate generates different SQL statements depending on the underlying application server?
How do i activate prepared statements generation in WebLogic?
SQL Log:
WebLogic-10.3:
Code:
SELECT DISTINCT
REIFENFELG0_.EOL_REIFEN_ID AS X0_0_, REIFENFELG0_.GROESSE AS X1_0_, REIFENFELG0_.NOTLAUF_X AS X2_0_, REIFENFELG0_.SOMMER_WINTER AS X3_0_, REIFENFELG0_.GUELTIG_VON AS X4_0_, REIFENFELG0_.GUELTIG_BIS AS X5_0_, REIFENFELG0_.TYP_JATO_ID AS X6_0_
FROM
EOL_REIFEN REIFENFELG0_
WHERE (((((((REIFENFELG0_.GROESSE LIKE '225/55R16%' ))
OR((REIFENFELG0_.GROESSE IS NULL )))
AND((REIFENFELG0_.NOTLAUF_X IS NULL )))
AND(((REIFENFELG0_.SOMMER_WINTER= 'S' ))
OR((REIFENFELG0_.SOMMER_WINTER IS NULL ))))
AND((((REIFENFELG0_.GUELTIG_BIS>= {TS '2008-11-11 10:39:56.003' } ))
OR((REIFENFELG0_.GUELTIG_BIS IS NULL )))
AND(((REIFENFELG0_.GUELTIG_VON<= {TS '2008-11-11 10:39:56.003' } ))
OR((REIFENFELG0_.GUELTIG_VON IS NULL )))))
AND(((REIFENFELG0_.TYP_JATO_ID= 720 ))
OR((REIFENFELG0_.TYP_JATO_ID IS NULL ))))
JBoss-4.2
Code:
SELECT DISTINCT
REIFENFELG0_.EOL_REIFEN_ID AS X0_0_, REIFENFELG0_.GROESSE AS X1_0_, REIFENFELG0_.NOTLAUF_X AS X2_0_, REIFENFELG0_.SOMMER_WINTER AS X3_0_, REIFENFELG0_.GUELTIG_VON AS X4_0_, REIFENFELG0_.GUELTIG_BIS AS X5_0_, REIFENFELG0_.TYP_JATO_ID AS X6_0_
FROM
EOL_REIFEN REIFENFELG0_
WHERE (((((((REIFENFELG0_.GROESSE LIKE '205/55R16%' ))
OR((REIFENFELG0_.GROESSE IS NULL )))
AND((REIFENFELG0_.NOTLAUF_X IS NULL )))
AND(((REIFENFELG0_.SOMMER_WINTER= 'S' ))
OR((REIFENFELG0_.SOMMER_WINTER IS NULL ))))
AND((((REIFENFELG0_.GUELTIG_BIS>= ? ))
OR((REIFENFELG0_.GUELTIG_BIS IS NULL )))
AND(((REIFENFELG0_.GUELTIG_VON<= ? ))
OR((REIFENFELG0_.GUELTIG_VON IS NULL )))))
AND(((REIFENFELG0_.TYP_JATO_ID= ? ))
OR((REIFENFELG0_.TYP_JATO_ID IS NULL ))))