2 Replies Latest reply on Nov 5, 2007 9:45 AM by daniel varga

    framework objects do not work with entities mapped in *.hbm.

    daniel varga Newbie


      I develop a web app which has it model classes in a separate jar that also contains the hbm.xml files for mapping the entities. The entities are accessed through standard JPA EntityManager. There are both query and home components declared in components.xml:

      <framework:entity-query name="subsystemList" ejbql="select s from CaasSubsystem s" max-results="1000" />
      <framework:entity-home name="subsystemHome" entity-class="com.comptel.cs.caas.pojo.CaasSubsystem" />

      Everything goes fine until I delete an entity with the home component. Then Seam.getEntityClass gets invoked and returns null, which in turn causes the following:
      Caused by: java.lang.IllegalArgumentException: Not an entity class: com.comptel.cs.caas.pojo.CaasSubsystem
      at org.jboss.seam.Entity.forClass(Entity.java:208)
      at org.jboss.seam.persistence.PersistenceProvider.getName(PersistenceProvider.java:75)
      at org.jboss.seam.persistence.HibernatePersistenceProvider.getName(HibernatePersistenceProvider.java:246)
      at org.jboss.seam.framework.EntityHome.getEntityName(EntityHome.java:123)
      at org.jboss.seam.framework.Home.getSimpleEntityName(Home.java:255)
      at org.jboss.seam.framework.Home.raiseAfterTransactionSuccessEvent(Home.java:250)
      at org.jboss.seam.framework.EntityHome.remove(EntityHome.java:64)

      This is because the Seam.getEntityClass checks for @javax.persisence.Entity annotation or ejb3 xml mapping, but it does not take into account that entities can mapped by hbm.xml files too.
      I tried using hibernate-entity-home and hibernate-entity-query components , but it did not help, but the exception occurred more often, not only after invoking remove on the entity home component.

      Annotating my classes with @Entity (which are mapped in *.hbm.xml!) helped, but it not a correct solution, because there might be some cases when the classes in the model package cannot be changed.

      Has anyone any idea how to work this around?