[hibernate-dev] MetadataSourceProcessor and associations

Hardy Ferentschik hardy at hibernate.org
Thu Jan 24 04:46:06 EST 2013


Hi,

as Steve is saying, you can basically mix and match hbm and annotation, however there is a caveat. 
Within one entity hierarchy you have to stick to one mapping approach. You cannot map the base class 
Animal in hbm and then use annotations for the subclass entity Dog.

If the entities are not related you can mix hbm and annotations. From a sources point of view I don't think
there is a problem with that. By the time you are consuming the sources all hbm and orm files should be parsed and
annotation should be processed.

How this exactly works with the current Binder and the "chasing" approach I am not sure of. 

--Hardy 



On 23 Jan 2013, at 8:13 PM, Gail Badner <gbadner at redhat.com> wrote:

> Is it possible for an entity containing one side of an association be mapped using annotations and the entity containing the opposite side of the association be mapped using an hbm mapping?
> 
> For example, suppose Order has annotations:
> 
> @OneToMany( mappedby="order" )
> List<OrderLine> Order.orderLines
> 
> OrderLine is mapped using hbm.xml with:
> 
> <many-to-one name="order"/>
> 
> If annotations are processed first, then, IIUC, when Order.orderLines is processed, the mapping for OrderLine won't be found (via chasing) because the AnnotationMetadataSourceProcessorImpl does not have the source for the OrderLine mapping. As a result, the OrderLine EntityBinding will not be able to be built until HbmMetadataSourceProcessorImpl is processed.
> 
> If so, this poses a fundamental problem with entity "chasing" as it is implemented now, since the associated entity would not be processed by the same MetadataSourceProcessor.
> 
> Am I missing something here?
> 
> Thanks,
> Gail
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev




More information about the hibernate-dev mailing list