Java 类org.hibernate.annotations.FetchProfile 实例源码

项目:lams    文件:VerifyFetchProfileReferenceSecondPass.java   
public void doSecondPass(Map persistentClasses) throws MappingException {
    org.hibernate.mapping.FetchProfile profile = mappings.findOrCreateFetchProfile(
            fetchProfileName,
            MetadataSource.ANNOTATIONS
    );
    if ( MetadataSource.ANNOTATIONS != profile.getSource() ) {
        return;
    }

    PersistentClass clazz = mappings.getClass( fetch.entity().getName() );
    // throws MappingException in case the property does not exist
    clazz.getProperty( fetch.association() );

    profile.addFetch(
            fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase()
    );
}
项目:lams    文件:VerifyFetchProfileReferenceSecondPass.java   
public VerifyFetchProfileReferenceSecondPass(
        String fetchProfileName,
        FetchProfile.FetchOverride fetch,
        Mappings mappings) {
    this.fetchProfileName = fetchProfileName;
    this.fetch = fetch;
    this.mappings = mappings;
}
项目:lams    文件:AnnotationBinder.java   
private static void bindFetchProfiles(XAnnotatedElement annotatedElement, Mappings mappings) {
    FetchProfile fetchProfileAnnotation = annotatedElement.getAnnotation( FetchProfile.class );
    FetchProfiles fetchProfileAnnotations = annotatedElement.getAnnotation( FetchProfiles.class );
    if ( fetchProfileAnnotation != null ) {
        bindFetchProfile( fetchProfileAnnotation, mappings );
    }
    if ( fetchProfileAnnotations != null ) {
        for ( FetchProfile profile : fetchProfileAnnotations.value() ) {
            bindFetchProfile( profile, mappings );
        }
    }
}
项目:lams    文件:AnnotationBinder.java   
private static void bindFetchProfile(FetchProfile fetchProfileAnnotation, Mappings mappings) {
    for ( FetchProfile.FetchOverride fetch : fetchProfileAnnotation.fetchOverrides() ) {
        org.hibernate.annotations.FetchMode mode = fetch.mode();
        if ( !mode.equals( org.hibernate.annotations.FetchMode.JOIN ) ) {
            throw new MappingException( "Only FetchMode.JOIN is currently supported" );
        }

        SecondPass sp = new VerifyFetchProfileReferenceSecondPass( fetchProfileAnnotation.name(), fetch, mappings );
        mappings.addSecondPass( sp );
    }
}