1 package org.hibernate.impl; 3 4 import java.util.HashMap ; 5 import java.util.Iterator ; 6 import java.util.List ; 7 import java.util.Map ; 8 9 import org.hibernate.FlushMode; 10 import org.hibernate.HibernateException; 11 import org.hibernate.LockMode; 12 import org.hibernate.Query; 13 import org.hibernate.ScrollMode; 14 import org.hibernate.ScrollableResults; 15 import org.hibernate.engine.QueryParameters; 16 import org.hibernate.engine.SessionImplementor; 17 18 24 public class QueryImpl extends AbstractQueryImpl { 25 26 private Map lockModes = new HashMap (2); 27 28 public QueryImpl(String queryString, FlushMode flushMode, SessionImplementor session) { 29 super(queryString, flushMode, session); 30 } 31 32 public QueryImpl(String queryString, SessionImplementor session) { 33 this(queryString, null, session); 34 } 35 36 public Iterator iterate() throws HibernateException { 37 verifyParameters(); 38 Map namedParams = getNamedParams(); 39 before(); 40 try { 41 return getSession().iterate( 42 bindParameterLists(namedParams), 43 getQueryParameters(namedParams) 44 ); 45 } 46 finally { 47 after(); 48 } 49 } 50 51 public ScrollableResults scroll() throws HibernateException { 52 return scroll( ScrollMode.SCROLL_INSENSITIVE ); 53 } 54 55 public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException { 56 verifyParameters(); 57 Map namedParams = getNamedParams(); 58 before(); 59 QueryParameters qp = getQueryParameters(namedParams); 60 qp.setScrollMode(scrollMode); 61 try { 62 return getSession().scroll( bindParameterLists(namedParams), qp ); 63 } 64 finally { 65 after(); 66 } 67 } 68 69 public List list() throws HibernateException { 70 verifyParameters(); 71 Map namedParams = getNamedParams(); 72 before(); 73 try { 74 return getSession().list( 75 bindParameterLists(namedParams), 76 getQueryParameters(namedParams) 77 ); 78 } 79 finally { 80 after(); 81 } 82 } 83 84 public int executeUpdate() throws HibernateException { 85 verifyParameters(); 86 Map namedParams = getNamedParams(); 87 before(); 88 try { 89 return getSession().executeUpdate( 90 bindParameterLists( namedParams ), 91 getQueryParameters( namedParams ) 92 ); 93 } 94 finally { 95 after(); 96 } 97 } 98 99 public Query setLockMode(String alias, LockMode lockMode) { 100 lockModes.put(alias, lockMode); 101 return this; 102 } 103 104 protected Map getLockModes() { 105 return lockModes; 106 } 107 108 } 109 110 111 112 113 114 115 | Popular Tags |