package com.tykj.dev.device.user.util;

import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.id.IncrementGenerator;

import java.io.Serializable;

/**
 * @author zjm
 * @version 1.0.0
 * @ClassName UserIdentityGenerator.java
 * @Description TODO
 * @createTime 2020年07月31日 09:47:00
 */
public class UserIdentityGenerator extends IncrementGenerator {
    public Serializable generate(SessionImplementor sessionImplementor, Object object) throws HibernateException {
        Serializable id = sessionImplementor.getEntityPersister(null, object)
                .getClassMetadata().getIdentifier(object, sessionImplementor);
        return id != null ? id : super.generate(sessionImplementor, object);
    }

}
