![JAR search and dependency download from the Maven repository](/logo.png)
org.gvnix.web.datatables.util.EntityManagerProviderImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.gvnix.web.datatables Show documentation
Show all versions of org.gvnix.web.datatables Show documentation
Dandelion-DataTables utilities for Spring MVC based projects.
The newest version!
/*
* Copyright 2015 DISID Corporation S.L. All rights reserved.
*
* Project : [PROJECT NAME]
* SVN Id : $Id$
*/
package org.gvnix.web.datatables.util;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import javax.persistence.EntityManager;
import org.springframework.stereotype.Service;
/**
* Service which provides EntityManager instance for a JPA Entity class from a
* ActiveRecord Spring-Roo entity
*
* @author gvNIX Team
* @deprecated use
* {@link org.gvnix.web.datatables.util.impl.EntityManagerProviderImpl}
*/
@Service
public class EntityManagerProviderImpl implements EntityManagerProvider {
/* (non-Javadoc)
* @see org.gvnix.web.datatables.util.EntityManagerProvider#getEntityManager(java.lang.Class)
*/
public EntityManager getEntityManager(Class klass) {
try {
Method[] methods = klass.getMethods();
for (Method method : methods) {
if ((method.getModifiers() & Modifier.STATIC) != 0) {
if (method.getReturnType() == EntityManager.class) {
method.setAccessible(true);
return (EntityManager) method.invoke(null, null);
}
}
}
}
catch (Exception e) {
throw new IllegalStateException(
"Error getting entity manager for domain class: ".concat(klass
.getName()), e);
}
throw new IllegalStateException(
"Cannot get entity manager for domain class: ".concat(klass
.getName()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy