Class SQLInspector

  • All Implemented Interfaces:
    Serializable, org.hibernate.resource.jdbc.spi.StatementInspector, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

    @Repository
    public class SQLInspector
    extends Object
    implements org.hibernate.resource.jdbc.spi.StatementInspector, org.springframework.context.ApplicationContextAware
    Hibernate Statement Inspector that provides support to Multitenancy databases. The strategy defined by the TOTVS Development Platform uses a discriminator column called tenant_id to logically separate tenants and Table Partitioning for performance reasons.
    See Also:
    Serialized Form
    • Constructor Detail

      • SQLInspector

        public SQLInspector()
    • Method Detail

      • inspect

        public String inspect​(String sql)
        Inspect SQL Statements renaming multitenant tables suffixing with the last part of the tenant UUID. Entities annotated with @SharedTable are not affected.
        Specified by:
        inspect in interface org.hibernate.resource.jdbc.spi.StatementInspector
        See Also:
        StatementInspector.inspect(java.lang.String)
      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
        Introspect, at startup, all application entity classes to fulfill a list of multitenant table names that will be use in the statement introspection process.
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
        See Also:
        ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)