All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.boot.model.source.internal.hbm.FetchProfileBinder Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.boot.model.source.internal.hbm;

import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmFetchProfileType;
import org.hibernate.mapping.FetchProfile;
import org.hibernate.mapping.MetadataSource;

import org.jboss.logging.Logger;

/**
 * @author Steve Ebersole
 */
public class FetchProfileBinder {
	private static final Logger log = Logger.getLogger( FetchProfileBinder.class );

	/**
	 * Handling for a {@code } declaration.
	 * 

* This form handles fetch profiles defined at the {@code } * root. For handling of fetch profiles defined within an entity, see * {@link #processFetchProfile(HbmLocalMetadataBuildingContext, org.hibernate.boot.jaxb.hbm.spi.JaxbHbmFetchProfileType, String)} * * @param context Access to information relative to the mapping document containing this binding * @param fetchProfileBinding The {@code } binding */ public static void processFetchProfile( HbmLocalMetadataBuildingContext context, JaxbHbmFetchProfileType fetchProfileBinding) { processFetchProfile( context, fetchProfileBinding, null ); } /** * Handling for a {@code } declaration. * * @param context Access to information relative to the mapping document containing this binding * @param fetchProfileBinding The {@code } binding * @param containingEntityName The name of the entity containing the fetch profile declaration. May * be {@code null} to indicate a fetch profile defined at the root. */ public static void processFetchProfile( HbmLocalMetadataBuildingContext context, JaxbHbmFetchProfileType fetchProfileBinding, String containingEntityName) { FetchProfile profile = context.getMetadataCollector().getFetchProfile( fetchProfileBinding.getName() ); if ( profile == null ) { log.debugf( "Creating FetchProfile : %s", fetchProfileBinding.getName() ); profile = new FetchProfile( fetchProfileBinding.getName(), MetadataSource.HBM ); context.getMetadataCollector().addFetchProfile( profile ); } for ( JaxbHbmFetchProfileType.JaxbHbmFetch fetchBinding : fetchProfileBinding.getFetch() ) { String entityName = fetchBinding.getEntity(); if ( entityName == null ) { entityName = containingEntityName; } if ( entityName == null ) { throw new org.hibernate.boot.MappingException( String.format( "Unable to determine entity for fetch-profile fetch [%s:%s]", profile.getName(), fetchBinding.getAssociation() ), context.getOrigin() ); } profile.addFetch( entityName, fetchBinding.getAssociation(), fetchBinding.getStyle().value() ); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy