-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: get all classes from archiv,which are annotiated as @entity
PostPosted: Wed Sep 27, 2006 7:01 pm 
Beginner
Beginner

Joined: Thu Sep 21, 2006 2:49 am
Posts: 24
The Configuration Object in a Java SE Hibernate Envirement provides the Method getClassMappings() to browse al the mapped classes. Is there some similar way to get all Classes from my archiv, which are annotiated as @entity?

Something like: EntityManager.getEJB3Configuration().getClassMappings();

Thank you in advance!

_________________
http://www.dooris.de


Top
 Profile  
 
 Post subject: Re: get all classes from archiv,which are annotiated as @ent
PostPosted: Fri Sep 29, 2006 6:23 am 
Beginner
Beginner

Joined: Thu Sep 21, 2006 2:49 am
Posts: 24
I am looking for a possibility to get all Entity- Classes, that are managed by the Container or the EntityManager.

Realy no Idea?

_________________
http://www.dooris.de


Top
 Profile  
 
 Post subject: get all managed entity beans
PostPosted: Tue Feb 13, 2007 5:57 am 
Beginner
Beginner

Joined: Thu Sep 21, 2006 2:49 am
Posts: 24
is there realy no solution??? is something to do with the class loader??

_________________
http://www.dooris.de


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 7:49 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
there is a way to keep the configuration around using the property hibernate.ejb.configuration_jndi_name

Or you can create your own Ejb3Configuration and keep it.

otherwise (it will be lighter wrt memory), you can do ( (EntityManager) session).getSessionFactory().getAllClassMetadata()

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 10:44 am 
Beginner
Beginner

Joined: Thu Sep 21, 2006 2:49 am
Posts: 24
Thank you for this advice. I created a statless Sessionbean as followed:

Code:
@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 that works fine!!

_________________
http://www.dooris.de


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.