01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.gps.device.hibernate;
18:
19: import org.compass.gps.device.hibernate.entities.EntityInformation;
20: import org.hibernate.Criteria;
21: import org.hibernate.Query;
22: import org.hibernate.Session;
23:
24: /**
25: * During indexing time provides the Hibernate Query to extract the data
26: * to be indexed per entity.
27: *
28: * <p>Can return either return <code>Query</code> or <code>Criteria</code>.
29: * Indexers ({@link org.compass.gps.device.hibernate.indexer.HibernateIndexEntitiesIndexer}
30: * are encouraged to first check the criteria, and if that returns <code>null</code>
31: * use the query.
32: *
33: * @author kimchy
34: */
35: public interface HibernateQueryProvider {
36:
37: /**
38: * Create a HIbnerate Query based on the Hibernate <code>Session</code> and
39: * the {@link org.compass.gps.device.hibernate.entities.EntityInformation}.
40: *
41: * @param session The Hibernate session to create the query with
42: * @param entityInformation The enity information to create the query with
43: * @return the Hibernate query
44: */
45: Query createQuery(Session session,
46: EntityInformation entityInformation);
47:
48: /**
49: * Create a Criteria query based on the <code>EntityManager</code>
50: * and the {@link org.compass.gps.device.hibernate.entities.EntityInformation}.
51: * Criteria queries respect customizations about eager fetching of
52: * collections.
53: *
54: * @param session The Hibernate session to create the query with
55: * @param entityInformation The enity information to create the query with
56: * @return the Hibernate query
57: */
58: Criteria createCriteria(Session session,
59: EntityInformation entityInformation);
60: }
|