Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1.3
Name and version of the database you are using: SQL Server
The generated SQL (show_sql=true):
SELECT f.*
FROM J INNER JOIN T ON t.jId = j.jId AND j.exjId = 'bbbbb''
INNER JOIN F f ON t.tenId=f.tenId
WHERE f.fin = 1 AND f.status!='X'
Takes 672 milis
SELECT f.fin, mr.sc
FROM M mr INNER JOIN FH fh ON mr.sFinHId=fh.finHId
INNER JOIN F f ON fh.finId=f.finId INNER JOIN Tt t ON f.tenId=t.tenId
INNER JOIN J j ON t.jId = j.jId AND j.exJId = 'aaaaaa'
WHERE mr.mfinid = 156
Takes 31 milis
I have problems whit a method that execute three queries in the worse case, but generally the amount of queries are two.
The problem is that the first query takes around of 650 milis and the others takes only 15 milis, and the queries are similars.
I have change the name of the Objects because i'm in a private corporation so don't answer syntax problems in the queries because there is no are.
The code to create the queries is this:
Query query = s.createSQLQuery(" First Query...")
F f = (F) query.uniqueResult(); //Takes 672 milis
if (f != null) {
query = s.createSQLQuery("Second Query...")
List<Object[]> values = query.list(); //Takes 31 milis
....
}