-->
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.  [ 1 post ] 
Author Message
 Post subject: overriding mapping definitions
PostPosted: Thu Apr 13, 2006 8:07 pm 
Newbie

Joined: Thu Apr 13, 2006 7:53 pm
Posts: 4
Hibernate version: 3.1.2

hi,

i am in a situation, where it would be helpful , if the following was possible: i specify two directory locations as locations for mapping file resources. the first one contains the standard mappings, the second one customer-specific mappings, which should override the mappings from the first location .
After checking the source it seems this could be achieved quite easily by adding an overrideMappingAllowed property to and changing the addClass(),addCollection() and addQuery() Methods in org.hibernate.cfg.Mappings along the lines of:

Code:
public void addClass(PersistentClass persistentClass) throws MappingException {

      Object old = classes.put( persistentClass.getEntityName(), persistentClass );

      if ( old!=null ) {

         throw new DuplicateMappingException( "class/entity", persistentClass.getEntityName() );

      }

   }



becomes:

Code:
public void addClass(PersistentClass persistentClass) throws MappingException {

      Object old = classes.put( persistentClass.getEntityName(), persistentClass );

      if ( old!=null && !overrideMappingAllowed ) {

         throw new DuplicateMappingException( "class/entity", persistentClass.getEntityName() );

      }

   }


could this have any undesired side effects? and if this change makes sense, would it be possible to get it into the source tree, so i do not have to use my own patched version of hibernate ?

Lutz


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

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.