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

org.babyfish.hibernate.persister.StandardPersisterClassResolver Maven / Gradle / Ivy

The newest version!
/*
 * BabyFish, Object Model Framework for Java and JPA.
 * https://github.com/babyfish-ct/babyfish
 *
 * Copyright (c) 2008-2015, Tao Chen
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * Please visit "http://opensource.org/licenses/LGPL-3.0" to know more.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 */
package org.babyfish.hibernate.persister;

import org.hibernate.mapping.PersistentClass;
import org.hibernate.metamodel.binding.EntityBinding;
import org.hibernate.persister.entity.EntityPersister;

/**
 * @author Tao Chen
 */
public class StandardPersisterClassResolver extends org.hibernate.persister.internal.StandardPersisterClassResolver {

    private static final long serialVersionUID = 3665499181700048132L;

    @Override
    public Class getEntityPersisterClass(EntityBinding metadata) {
        return replace(super.getEntityPersisterClass(metadata));
    }

    @Override
    public Class getEntityPersisterClass(PersistentClass metadata) {
        
        return replace(super.getEntityPersisterClass(metadata));
    }

    private static Class replace(Class persisterClass)  {
        if (persisterClass == org.hibernate.persister.entity.SingleTableEntityPersister.class) {
            return SingleTableEntityPersister.class;
        }
        if (persisterClass == org.hibernate.persister.entity.UnionSubclassEntityPersister.class) {
            return UnionSubclassEntityPersister.class;
        }
        if (persisterClass == org.hibernate.persister.entity.JoinedSubclassEntityPersister.class) {
            return JoinedSubclassEntityPersister.class;
        }
        return persisterClass;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy