/** * Read mappings from a particular XML file * * @param xmlFile a path to a file * @return this (for method chaining purposes) * @throws MappingException Indicates inability to locate the specified mapping file. */ public Configuration addFile(File xmlFile) throws MappingException { metadataSources.addFile( xmlFile ); return this; }
/** * Read mappings from a particular XML file * * @param xmlFile a path to a file * @return this (for method chaining purposes) * @throws org.hibernate.MappingException Indicates inability to locate or parse * the specified mapping file. * @see #addFile(java.io.File) */ public Configuration addFile(String xmlFile) throws MappingException { metadataSources.addFile( xmlFile ); return this; } /**
/** * Read mappings from a particular XML file * * @param path The path to a file. Expected to be resolvable by {@link java.io.File#File(String)} * * @return this (for method chaining purposes) * * @see #addFile(java.io.File) */ public MetadataSources addFile(String path) { addFile( new File( path ) ); return this; }
private void configure(MetadataSources metadataSources) { for ( String filename : collectFiles() ) { if ( filename.endsWith(".jar") ) { metadataSources.addJar( new File( filename ) ); } else { metadataSources.addFile( filename ); } } }
private void configure(MetadataSources metadataSources) { for ( String filename : collectFiles() ) { if ( filename.endsWith( ".jar" ) ) { metadataSources.addJar( new File( filename ) ); } else { metadataSources.addFile( filename ); } } }
/** * Read all mapping documents from a directory tree. * <p/> * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document. * * @param dir The directory * * @return this (for method chaining purposes) * * @throws org.hibernate.MappingException Indicates problems reading the jar file or * processing the contained mapping documents. */ public MetadataSources addDirectory(File dir) { File[] files = dir.listFiles(); if ( files != null && files.length > 0 ) { for ( File file : files ) { if ( file.isDirectory() ) { addDirectory( file ); } else if ( file.getName().endsWith( ".hbm.xml" ) ) { addFile( file ); } } } return this; }
private static MetadataImplementor buildMetadata( CommandLineArgs parsedArgs, StandardServiceRegistry serviceRegistry) throws Exception { final MetadataSources metadataSources = new MetadataSources(serviceRegistry); for ( String filename : parsedArgs.hbmXmlFiles ) { metadataSources.addFile( filename ); } for ( String filename : parsedArgs.jarFiles ) { metadataSources.addJar( new File( filename ) ); } final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder(); final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class ); if ( parsedArgs.implicitNamingStrategy != null ) { metadataBuilder.applyImplicitNamingStrategy( strategySelector.resolveStrategy( ImplicitNamingStrategy.class, parsedArgs.implicitNamingStrategy ) ); } if ( parsedArgs.physicalNamingStrategy != null ) { metadataBuilder.applyPhysicalNamingStrategy( strategySelector.resolveStrategy( PhysicalNamingStrategy.class, parsedArgs.physicalNamingStrategy ) ); } return (MetadataImplementor) metadataBuilder.build(); }
private static MetadataImplementor buildMetadata(CommandLineArgs parsedArgs, ServiceRegistry serviceRegistry) throws Exception { final MetadataSources metadataSources = new MetadataSources( serviceRegistry ); for ( String filename : parsedArgs.hbmXmlFiles ) { metadataSources.addFile( filename ); } for ( String filename : parsedArgs.jarFiles ) { metadataSources.addJar( new File( filename ) ); } final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder(); final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class ); if ( parsedArgs.implicitNamingStrategyImplName != null ) { metadataBuilder.applyImplicitNamingStrategy( strategySelector.resolveStrategy( ImplicitNamingStrategy.class, parsedArgs.implicitNamingStrategyImplName ) ); } if ( parsedArgs.physicalNamingStrategyImplName != null ) { metadataBuilder.applyPhysicalNamingStrategy( strategySelector.resolveStrategy( PhysicalNamingStrategy.class, parsedArgs.physicalNamingStrategyImplName ) ); } return (MetadataImplementor) metadataBuilder.build(); }
private static MetadataImplementor buildMetadata( CommandLineArgs parsedArgs, StandardServiceRegistry serviceRegistry) throws Exception { final MetadataSources metadataSources = new MetadataSources( serviceRegistry ); for ( String filename : parsedArgs.hbmXmlFiles ) { metadataSources.addFile( filename ); } for ( String filename : parsedArgs.jarFiles ) { metadataSources.addJar( new File( filename ) ); } final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder(); final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class ); if ( parsedArgs.implicitNamingStrategyImplName != null ) { metadataBuilder.applyImplicitNamingStrategy( strategySelector.resolveStrategy( ImplicitNamingStrategy.class, parsedArgs.implicitNamingStrategyImplName ) ); } if ( parsedArgs.physicalNamingStrategyImplName != null ) { metadataBuilder.applyPhysicalNamingStrategy( strategySelector.resolveStrategy( PhysicalNamingStrategy.class, parsedArgs.physicalNamingStrategyImplName ) ); } return (MetadataImplementor) metadataBuilder.build(); }
public void apply(MetadataSources metadataSources) { switch ( getType() ) { case RESOURCE: { metadataSources.addResource( getReference() ); break; } case CLASS: { metadataSources.addAnnotatedClassName( getReference() ); break; } case FILE: { metadataSources.addFile( getReference() ); break; } case PACKAGE: { metadataSources.addPackage( getReference() ); break; } case JAR: { metadataSources.addJar( new File( getReference() ) ); break; } } } }
sources.addFile( new File( "./mapping.xml") );
metadataSources.addFile( fileName );
/** * Read mappings from a particular XML file * * @param xmlFile a path to a file * @return this (for method chaining purposes) * @throws MappingException Indicates inability to locate the specified mapping file. */ public Configuration addFile(File xmlFile) throws MappingException { metadataSources.addFile( xmlFile ); return this; }
/** * Read mappings from a particular XML file * * @param xmlFile a path to a file * @return this (for method chaining purposes) * @throws org.hibernate.MappingException Indicates inability to locate or parse * the specified mapping file. * @see #addFile(java.io.File) */ public Configuration addFile(String xmlFile) throws MappingException { metadataSources.addFile( xmlFile ); return this; } /**
/** * Read mappings from a particular XML file * * @param path The path to a file. Expected to be resolvable by {@link java.io.File#File(String)} * * @return this (for method chaining purposes) * * @see #addFile(java.io.File) */ public MetadataSources addFile(String path) { addFile( new File( path ) ); return this; }
private void configure(MetadataSources metadataSources) { for ( String filename : collectFiles() ) { if ( filename.endsWith(".jar") ) { metadataSources.addJar( new File( filename ) ); } else { metadataSources.addFile( filename ); } } }
private void configure(MetadataSources metadataSources) { for ( String filename : collectFiles() ) { if ( filename.endsWith( ".jar" ) ) { metadataSources.addJar( new File( filename ) ); } else { metadataSources.addFile( filename ); } } }
public NativeMetadataDescriptor( File cfgXmlFile, File[] mappingFiles, Properties properties) { BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build(); ssrb = new StandardServiceRegistryBuilder(bsr); if (cfgXmlFile != null) { ssrb.configure(cfgXmlFile); } if (properties != null) { this.properties.putAll(properties); } ssrb.applySettings(getProperties()); metadataSources = new MetadataSources(bsr); if (mappingFiles != null) { for (File file : mappingFiles) { if (file.getName().endsWith(".jar")) { metadataSources.addJar(file); } else { metadataSources.addFile(file); } } } }
public NativeMetadataDescriptor( File cfgXmlFile, File[] mappingFiles, Properties properties) { BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build(); ssrb = new StandardServiceRegistryBuilder(bsr); if (cfgXmlFile != null) { ssrb.configure(cfgXmlFile); } if (properties != null) { this.properties.putAll(properties); } ssrb.applySettings(getProperties()); metadataSources = new MetadataSources(bsr); if (mappingFiles != null) { for (File file : mappingFiles) { if (file.getName().endsWith(".jar")) { metadataSources.addJar(file); } else { metadataSources.addFile(file); } } } }
public void apply(MetadataSources metadataSources) { switch ( getType() ) { case RESOURCE: { metadataSources.addResource( getReference() ); break; } case CLASS: { metadataSources.addAnnotatedClassName( getReference() ); break; } case FILE: { metadataSources.addFile( getReference() ); break; } case PACKAGE: { metadataSources.addPackage( getReference() ); break; } case JAR: { metadataSources.addJar( new File( getReference() ) ); break; } } } }