/** * Short-hand form of calling {@link #getMetadataBuilder()} and using its * {@link org.hibernate.boot.MetadataBuilder#build()} method in cases where the application wants * to accept the defaults. * * @return The built metadata. */ public Metadata buildMetadata() { return getMetadataBuilder().build(); }
/** * Read metadata from the annotations associated with this class. * * @param annotatedClass The class containing annotations * * @return this (for method chaining) */ @SuppressWarnings({ "unchecked" }) public Configuration addAnnotatedClass(Class annotatedClass) { metadataSources.addAnnotatedClass( annotatedClass ); return this; }
@Override public SessionFactory build() { return delegate.build(); } }
/** * Create a new LocalSessionFactoryBuilder for the given DataSource. * @param dataSource the JDBC DataSource that the resulting Hibernate SessionFactory should be using * (may be {@code null}) * @param resourceLoader the ResourceLoader to load application classes from */ public LocalSessionFactoryBuilder(@Nullable DataSource dataSource, ResourceLoader resourceLoader) { this(dataSource, resourceLoader, new MetadataSources( new BootstrapServiceRegistryBuilder().applyClassLoader(resourceLoader.getClassLoader()).build())); }
private Metadata buildMappings(StandardServiceRegistry registry) { return new MetadataSources( registry ) .addAnnotatedClass( MyEntity.class ) .buildMetadata(); }
@Override public MetadataBuilder getMetadataBuilder() { MetadataBuilder metadataBuilder = super.getMetadataBuilder(); metadataBuilder.applyImplicitSchemaName( "default-schema" ); return metadataBuilder; } };
@Override protected void configureMetadataBuilder(MetadataBuilder metadataBuilder) { metadataBuilder.applyImplicitNamingStrategy( (ImplicitNamingStrategy) TestNamingStrategy.INSTANCE ); metadataBuilder.applyPhysicalNamingStrategy( (PhysicalNamingStrategy) TestNamingStrategy.INSTANCE ); }
protected void initialize(MetadataBuilder metadataBuilder) { metadataBuilder.enableNewIdentifierGeneratorSupport( true ); metadataBuilder.applyImplicitNamingStrategy( ImplicitNamingStrategyLegacyJpaImpl.INSTANCE ); }
@Override protected void configureMetadataBuilder(MetadataBuilder metadataBuilder) { metadataBuilder.applyImplicitNamingStrategy( ImplicitNamingStrategyLegacyHbmImpl.INSTANCE ); }
/** * Read mappings as a application resourceName (i.e. classpath lookup) * trying different class loaders. * * @param resourceName The resource name * @return this (for method chaining purposes) * @throws MappingException Indicates problems locating the resource or * processing the contained mapping document. */ public Configuration addResource(String resourceName) throws MappingException { metadataSources.addResource( resourceName ); return this; }
/** * Read package-level metadata. * * @param packageName java package name * * @return this (for method chaining) * * @throws MappingException in case there is an error in the mapping data */ public Configuration addPackage(String packageName) throws MappingException { metadataSources.addPackage( packageName ); return this; }
/** * 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 all mappings from a jar file * <p/> * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document. * * @param jar a jar file * @return this (for method chaining purposes) * @throws MappingException Indicates problems reading the jar file or * processing the contained mapping documents. */ public Configuration addJar(File jar) throws MappingException { metadataSources.addJar( jar ); return this; }
/** * Read mappings from an {@link java.io.InputStream}. * * @param xmlInputStream The input stream containing a DOM. * @return this (for method chaining purposes) * @throws MappingException Indicates problems reading the stream, or * processing the contained mapping document. */ public Configuration addInputStream(InputStream xmlInputStream) throws MappingException { metadataSources.addInputStream( xmlInputStream ); return this; }
/** * Read mappings from a <tt>URL</tt> * * @param url The url for the mapping document to be read. * @return this (for method chaining purposes) * @throws MappingException Indicates problems reading the URL or processing * the mapping document. */ public Configuration addURL(URL url) throws MappingException { metadataSources.addURL( url ); return this; }
@Override protected void configure(SessionFactoryBuilder sfb) { sfb.applyCurrentTenantIdentifierResolver( currentTenantResolver ); }
public Metadata buildMetadata(StandardServiceRegistry serviceRegistry) { return getMetadataBuilder( serviceRegistry ).build(); }
@Override public MetadataBuilder getMetadataBuilder() { MetadataBuilder metadataBuilder = super.getMetadataBuilder(); metadataBuilder.applyImplicitSchemaName( "default-schema" ); return metadataBuilder; } };
@Override protected void applySources(MetadataSources metadataSources) { metadataSources.addAnnotatedClass( Address.class ) .addAnnotatedClass( Customer.class ) .addAnnotatedClass( Industry.class ) .addAnnotatedClass( Order.class ) .addAnnotatedClass( ZipCode.class ); } }
@Override protected void applySources(MetadataSources metadataSources) { metadataSources.addResource( "org/hibernate/test/namingstrategy/complete/Mappings.hbm.xml" ); } }