[jboss-user] [EJB 3.0] - Re: Retrieve retrieve Entity Class mapping from jboss
florian79
do-not-reply at jboss.com
Fri Feb 16 09:51:49 EST 2007
I created a statless Sessionbean as followed:
| @Stateless
| public class BaseSession implements BaseSessionRemote, BaseSessionLocal
| {
|
| @Resource SessionContext context;
| @PersistenceContext(unitName="myName") private EntityManager entityManager;
|
| public Map<String,EntityPersister> getAllClassMetadata()
| {
| Map<String,EntityPersister> metadata = null;
| try
| {
| HibernateEntityManager hibernateEntityManager = (HibernateEntityManager)entityManager.getDelegate();
| metadata = hibernateEntityManager.getSession().getSessionFactory().getAllClassMetadata();
| }
| catch(ClassCastException e)
| {
| LoggerImpl.getInstance().log(Logger.iLOGG_ERROR, this, e);
| metadata = new HashMap<String,EntityPersister>();
| }
| return metadata;
| }
| }
|
|
and then iterate over all maped entities:
| Map m = myPortalSession.getEntityManager().getAllClassMetadata();
| Set<Map.Entry> s = m.entrySet();
| for (Map.Entry e : s)
| {
| System.out.println(e.getKey() + "--->" + e.getValue());
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4017649#4017649
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4017649
More information about the jboss-user
mailing list