package com.icomsys.main_vm.common.filter;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.EmptyInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class HibernateInterceptor extends EmptyInterceptor {

    @Value("${spring.datasource.owner}")
    private String ownerAndSchema;
    @Value("${spring.config.activate.on-profile}")
    private String profile;
    @Override
    public String onPrepareStatement(String sql) {
        log.info("profile = {}", profile);
        log.info("sql = {}", sql);
//        if(profile.equals("create")){
//            sql = sql.replaceAll("#ownerAndSchema#", ownerAndSchema);
//        }
//        else{
//            sql = sql.replaceAll("#ownerAndSchema#.", "");
//        }
        return super.onPrepareStatement(sql);
//        return sql;
    }


}
