[hibernate-dev] how to get an EntityBinding by class name?

Strong Liu stliu at hibernate.org
Fri Jul 6 10:59:13 EDT 2012


okay, let me summary it here and see if i get it correct

1. entitybinding is keyed by (hibernate) entity name in metamodel
2. (hibernate) entity name should be FQN of the entity class (both hbm and annotation?)
3. it is correct assumption to throw exception when needs to look up an entitybinding but only entity class name provided by mapping and there is another entity name mapped to the same entity class 

On Jul 6, 2012, at 10:31 PM, Steve Ebersole wrote:

> Ok, should have gone back to original question 
> 
> Yes, you can name either Class name or entity-name, here.  In fact thats true of most of the Hibernate APIs.  Its a historical thing. Before Hibernate APIs were just like the JPA APIs in that you could only reference entities by Class reference.  With the development of the entity-name feature, thats no longer always possible. 
> 
> We left the Class-reference forms available (non-deprecated) since if your application is not using entity-names that is still a valid way to reference the mappings/persisters because there is a one-to-one correspondence.  Otherwise, as already pointed out on this thread, you have a many-to-one correspondence (*a* single Class might reference multiple entity mappings). 
> 
> On 07/06/2012 04:28 AM, Strong Liu wrote:
>> Hi,
>> 
>> having a question as $subject.
>> 
>> the return element (org.hibernate.internal.jaxb.mapping.hbm.JaxbReturnElement) has both entity name and class name attributes, and we are supposed to use one of them to get the target EntityBinding.
>> 
>> though look up entitybinding by entityname is easy, but I'm not sure how to look up entitybinding by class name, for now, i have used a stupid way, iterator the whole entitybindings within Metadata
>> 
>> org.hibernate.metamodel.internal.source.annotations.global.SqlResultSetProcessor#bindEntityResult
>> 
>> wondering if there is a better way to deal with this.
>> -------------------------
>> Best Regards,
>> 
>> Strong Liu <stliu at hibernate.org>
>> http://about.me/stliu/bio
>> 
>> _______________________________________________
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
> 
> 
> 
> -- 
> steve at hibernate.org
> http://hibernate.org

-------------------------
Best Regards,

Strong Liu <stliu at hibernate.org>
http://about.me/stliu/bio



More information about the hibernate-dev mailing list