-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Priority when co-existing Annot., orm.xml and hbm.xml?
PostPosted: Wed Dec 15, 2010 1:01 pm 
Beginner
Beginner

Joined: Wed Oct 08, 2008 10:59 am
Posts: 37
Assume I use JPA with Hibernate as implementation.

Accidentially or intentionally in my project there are
- Annotations in Java source
- orm.xml
and
- xxxx.hbm.xml
config files.

With contradicting mappings.

Which one has priority?

Can they co-exist at all or will there be an error (at runtime)?

Can I define a different priority hierarchy (If yes: How?) ?

Peter


Top
 Profile  
 
 Post subject: Re: Priority when co-existing Annot., orm.xml and hbm.xml?
PostPosted: Thu Dec 16, 2010 5:21 am 
Regular
Regular

Joined: Thu May 07, 2009 5:56 am
Posts: 94
Location: Toulouse, France
according to hibernate doc [1]
Quote:
You can mix annotated persistent classes and classic hbm.cfg.xml declarations with the same SessionFactory. You can however not declare a class several times (whether annotated or through hbm.xml). You cannot mix configuration strategies (hbm vs annotations) in an entity hierarchy either.

Quote:
To ease the migration process from hbm files to annotations, the configuration mechanism detects the mapping duplication between annotations and hbm files. HBM files are then prioritized over annotated metadata on a class to class basis. You can change the priority using hibernate.mapping.precedence property. The default is hbm, class, changing it to class, hbm will prioritize the annotated classes over hbm files when a conflict occurs.


[1] http://docs.jboss.org/hibernate/stable/ ... ml_single/

_________________
everything should be made as simple as possible, but not simpler (AE)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.