Gavin,
It don't work with oracle 8.0 if it have order by - oracle 8.0 and less don't supprot order by in view
This is test :
Code:
package yu.co.snpe.dbtable.test.hibernate;
import java.util.List;
import yu.co.snpe.dbtable.model.hibernate.FinNks;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
public class MaxResultSetTests extends BaseHibernateTests {
public MaxResultSetTests(String name) {
super(name);
}
public void testMaxResultsSuccess1() {
String query = "from " + FinNks.class.getName() + " where kon=20100";
try {
Query q = getSession().createQuery(query);
q.setMaxResults(100);
List list = q.list();
assertTrue("query",true);
} catch (HibernateException e) {
assertTrue("query",false);
}
}
public void testMaxResultsSuccess2() {
String query = "from " + FinNks.class.getName() + " where kon=20100 order by nk";
try {
Query q = getSession().createQuery(query);
//q.setMaxResults(100);
List list = q.list();
assertTrue("query",true);
} catch (HibernateException e) {
assertTrue("query",false);
}
}
public void testMaxResultsFail() {
String query = "from " + FinNks.class.getName() + " where kon=20100 order by nk";
try {
Query q = getSession().createQuery(query);
q.setMaxResults(100);
List list = q.list();
assertTrue("query",true);
} catch (HibernateException e) {
assertTrue("query",false);
}
}
}
This is SQL and error :
[/quote]Hibernate: select * from ( select finnks0_.NK as NK, finnks0_.RED as RED, finnks0_.DATD as DATD, finnks0_.DATV as DATV, finnks0_.DUG as DUG, finnks0_.POT as POT, finnks0_.SIFD as SIFD, finnks0_.KIFKUF as KIFKUF, finnks0_.ANAL as ANAL, finnks0_.DUGS as DUGS, finnks0_.POTS as POTS, finnks0_.KON as KON, finnks0_.OPN as OPN, finnks0_.VAL as VAL from SNPE2003.FIN_NKS finnks0_ where (kon=20100 ) ) where rownum <= ?
Hibernate: select finnks0_.NK as NK, finnks0_.RED as RED, finnks0_.DATD as DATD, finnks0_.DATV as DATV, finnks0_.DUG as DUG, finnks0_.POT as POT, finnks0_.SIFD as SIFD, finnks0_.KIFKUF as KIFKUF, finnks0_.ANAL as ANAL, finnks0_.DUGS as DUGS, finnks0_.POTS as POTS, finnks0_.KON as KON, finnks0_.OPN as OPN, finnks0_.VAL as VAL from SNPE2003.FIN_NKS finnks0_ where (kon=20100 ) order by nk
Hibernate: select * from ( select finnks0_.NK as NK, finnks0_.RED as RED, finnks0_.DATD as DATD, finnks0_.DATV as DATV, finnks0_.DUG as DUG, finnks0_.POT as POT, finnks0_.SIFD as SIFD, finnks0_.KIFKUF as KIFKUF, finnks0_.ANAL as ANAL, finnks0_.DUGS as DUGS, finnks0_.POTS as POTS, finnks0_.KON as KON, finnks0_.OPN as OPN, finnks0_.VAL as VAL from SNPE2003.FIN_NKS finnks0_ where (kon=20100 ) order by nk ) where rownum <= ?
[WARN,JDBCExceptionReporter,main] SQL Error: 907, SQLState: 42000
[ERROR,JDBCExceptionReporter,main] ORA-00907: missing right parenthesis
[WARN,JDBCExceptionReporter,main] SQL Error: 907, SQLState: 42000
[ERROR,JDBCExceptionReporter,main] ORA-00907: missing right parenthesis
Quote:
Oracle >=8.1 work fine (it support order by in view)
regards