All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.search.engine.impl.HibernateStatelessInitializer Maven / Gradle / Ivy

/*
 * Hibernate Search, full-text search for your domain model
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or .
 */

package org.hibernate.search.engine.impl;

import java.util.Collection;
import java.util.Map;

import org.hibernate.search.backend.spi.Work;
import org.hibernate.search.spi.InstanceInitializer;
import org.hibernate.search.hcore.util.impl.HibernateHelper;

/**
 * To be used for Hibernate initializations which don't need a specific Session.
 * {@link #initializeCollection(Collection)} and {@link #initializeMap(Map)}
 * are not supported.
 *
 * @author Sanne Grinovero (C) 2011 Red Hat Inc.
 */
public class HibernateStatelessInitializer implements InstanceInitializer {

	public static final HibernateStatelessInitializer INSTANCE = new HibernateStatelessInitializer();

	protected HibernateStatelessInitializer() {
		// should not create instances, but allow for extension
	}

	@Override
	public  Class getClass(T entity) {
		return HibernateHelper.getClass( entity );
	}

	@Override
	public Object unproxy(Object instance) {
		return HibernateHelper.unproxy( instance );
	}

	@Override
	public  Collection initializeCollection(Collection value) {
		// supports pass-through only, would need HibernateSessionLoadingInitializer
		return value;
	}

	@Override
	public  Map initializeMap(Map value) {
		// supports pass-through only, would need HibernateSessionLoadingInitializer
		return value;
	}

	@Override
	public Object[] initializeArray(Object[] value) {
		// hibernate doesn't allow lazy initialization of arrays,
		// so this must be initialized already.
		return value;
	}

	@Override
	public Class getClassFromWork(Work work) {
		return HibernateHelper.getClassFromWork( work );
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy