Class SQLInspector
- java.lang.Object
-
- com.totvs.tjf.tenant.discriminator.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 Summary
Constructors Constructor Description SQLInspector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
inspect(String sql)
Inspect SQL Statements renaming multitenant tables suffixing with the last part of the tenant UUID.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.
-
-
-
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 interfaceorg.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 interfaceorg.springframework.context.ApplicationContextAware
- See Also:
ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
-
-