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

com.talk2object.plum.repository.hibernate.HibernateUtils Maven / Gradle / Ivy

There is a newer version: 0.1.22
Show newest version
package com.talk2object.plum.repository.hibernate;

import org.hibernate.SessionFactory;
import org.hibernate.metadata.ClassMetadata;

import com.talk2object.plum.repository.biz.HibernateCollection;
import com.talk2object.plum.repository.biz.interafce.Collection;
import com.talk2object.plum.repository.biz.interafce.Repository;
import com.talk2object.plum.repository.meta.EntityMetaBuilder;

public class HibernateUtils {

	public static void registerEntityClasses(Repository repo,
			SessionFactory sessionFactory) {
		for (ClassMetadata cm : sessionFactory.getAllClassMetadata().values()) {
			register(repo, cm.getMappedClass(), sessionFactory);

		}
	}

	private static void register(Repository repo, Class clazz,
			SessionFactory sessionFactory) {

		Collection collection = new HibernateCollection(sessionFactory, clazz);

		EntityMetaBuilder emb = new EntityMetaBuilder(clazz);
		repo.register(emb.build(), collection);

	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy