[jboss-user] [EJB 3.0] - Re: Web Beans + JPA

skajotde do-not-reply at jboss.com
Wed Apr 15 08:07:44 EDT 2009

"epbernard" wrote : If we are OK to go the non standard route, I can look at adding  a method on HibernateEntityManagerFactory. 
  | Set<Class<?>> getEntities();
  |  returning the list of entities.
  | Or even better you can do
  | Collection metadatas = (Map) ( (HibernateEntityManagerFactory) emf ).getSessionFactory().getAllClassMetadata().values();
  | for(ClassMetadata metadata : metadatas) {
  |   Class<?> entityType = metadata.getMappedClass(EntityMode.POJO);
  |   if (entityType != null) 
  |     doStuffCauseItsAnEntity( entityType );
  | }

I think it is good way, so 

public Collection<Class<?>> discoverEntities();

is executed in context of deployed PU. EMF should take responsibility to discover which entities belong to it and expose API to get that information. So code for hibernate is ready, and for EMF which now doesn't expose similair API code discoverEntities should throw exception ..?

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4225600#4225600

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4225600

More information about the jboss-user mailing list