>> In Hibernate you can map the same class multiple times using >> different entity names. The map of entity bindings kept in Metadata >> contains >> all entity bindings keyed against these unique names. Trying to look >> up a binding by class name is not unique and we would have to deal with >> multiple bindings. >> >> >From a JPA perspective you cannot map a class multiple times. You >> can give it an alternate name via @Entity#name, but that's about it >> (names >> must be unique within the persistence unit). If I am not mistaken atm >> JPA entities are mapped in the entityBindingMap map using the >> unqualified >> class name (which is probably wrong).
That would be an error if that is true. They definitely should be getting keyed by their entity-name (which in normal cases is the FQN of the entity class). >> In the source interfaces we have: >> >> EntitySource#getEntityName() - this is the Hibernate notion of an entity name. In JPA this will always be the same as the entity class name. In Hibernate this is the entity name associated with this entity mapping. As Hardy points out this can be multiple entity names pointing to the same entity class. >> EntitySource#getClassName() - this is the string representation of the entity class name (its Class#getName). This can potentially be null eventually using Hibernate notion of MAP entity mode, though we really have not integrated that into the metamodel code as of yet. >> EntitySource#getJpaEntityName() // taken from @Entity#name - this is the JPA @Entity#name value as already pointed out. In HBM cases this will be null. >> Last but not least, looking at @EntityResult I can see that the >> connection to the corresponding entity is made via a Class reference >> (EntityResult#entityClass()), not >> by name. I guess that's why you need to this in the lookup in the >> first place. For this use case iterating seems fair enough for the >> moment. Any JPA API is going to deal with the @Entity Class reference. In those cases the correct thing to do is to resolve that Class to entity-name using Class#getName and do the lookup. If we want to support something like @EntityResult with Hibernate-style entity-names we will need to provide a another "alternate" (set of) annotation(s) to accept the String entityName. -- st...@hibernate.org http://hibernate.org _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev