package com.eactive.eai.rms.common.interceptor.jpa;

import org.hibernate.EmptyInterceptor;

import com.eactive.eai.rms.common.datasource.DataSourceContextHolder;

public class DynamicSchemaInterceptor extends EmptyInterceptor {

    @Override
    public String onPrepareStatement(String sql) {
        String schema = DataSourceContextHolder.getDataSourceType().getSchema();
        sql = sql.replaceAll("#schema#", schema);
        return super.onPrepareStatement(sql);
    }
}
