-->
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.  [ 4 posts ] 
Author Message
 Post subject: Serialized mapping files
PostPosted: Mon Aug 15, 2005 10:00 am 
Beginner
Beginner

Joined: Wed Aug 18, 2004 10:03 am
Posts: 28
Hi,

I'm useing Configuration.addCacheableFile(File) to load mapping files, but i have a problem when i put mapping files into jar file.
Do you know how to call addCacheableFile with files from jar ?

regards
epsino


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 10:57 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Hmmm ... looking at the addCachable code, I think you will have to override it to look for the files inside .jar.
Look at how normal .hbm.xml files are loadad from .jar (addJar() method).

Code:
   public Configuration addJar(File jar) throws MappingException {

      log.info( "Searching for mapping documents in jar: " + jar.getName() );

      final JarFile jarFile;
      try {
         jarFile = new JarFile( jar );
      }
      catch ( IOException ioe ) {
         throw new MappingException( "Could not read mapping documents from jar: " + jar.getName(), ioe );
      }

      Enumeration jarEntries = jarFile.entries();
      while ( jarEntries.hasMoreElements() ) {

         ZipEntry ze = ( ZipEntry ) jarEntries.nextElement();

         if ( ze.getName().endsWith( ".hbm.xml" ) ) {
            log.info( "Found mapping document in jar: " + ze.getName() );
            try {
               addInputStream( jarFile.getInputStream( ze ) );
            }
            catch ( Exception e ) {
               throw new MappingException( "Could not read mapping documents from jar: " + jar.getName(), e );
            }
         }
      }

      return this;

   }


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 2:36 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Was there a resolution to this? I've migrated an app from 2 to 3 and there are > 60 mappings in a jar . Everything I find in the dox addresses regular mapping files.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 2:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
add a request to jira


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.