Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* Copyright 2013 David Wolverton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.googlecode.genericdao.search.hibernate;
import com.googlecode.genericdao.search.*;
import org.hibernate.NonUniqueResultException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.ResultTransformer;
import org.hibernate.transform.Transformers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
/**
* Implementation of BaseSearchProcessor that generates Works with standard Hibernate.
*
* A singleton instance of this class is maintained for each SessionFactory. This should
* be accessed using {@link HibernateSearchProcessor#getInstanceForSessionFactory(SessionFactory)}.
*
* @author dwolverton
*/
public class HibernateSearchProcessor extends BaseSearchProcessor {
private static Logger logger = LoggerFactory.getLogger(HibernateSearchProcessor.class);
private static Map map = new HashMap();
public static HibernateSearchProcessor getInstanceForSessionFactory(SessionFactory sessionFactory) {
HibernateSearchProcessor instance = map.get(sessionFactory);
if (instance == null) {
instance = new HibernateSearchProcessor(HibernateMetadataUtil.getInstanceForSessionFactory(sessionFactory));
map.put(sessionFactory, instance);
}
return instance;
}
private HibernateSearchProcessor(HibernateMetadataUtil mdu) {
super(QLTYPE_HQL, mdu);
}
// --- Public Methods ---
/**
* Search for objects based on the search parameters in the specified
* ISearch object.
*
* @see ISearch
*/
@SuppressWarnings("unchecked")
public List search(Session session, ISearch search) {
if (search == null)
return null;
return search(session, search.getSearchClass(), search);
}
/**
* Search for objects based on the search parameters in the specified
* ISearch object. Uses the specified searchClass, ignoring the
* searchClass specified on the search itself.
*
* @see ISearch
*/
@SuppressWarnings("unchecked")
public List search(Session session, Class> searchClass, ISearch search) {
if (searchClass == null || search == null)
return null;
List