Class DbAdmin

java.lang.Object
tech.ailef.dbadmin.external.DbAdmin

@Component public class DbAdmin extends Object
The main DbAdmin class responsible for the initialization phase. This class scans the user provided package containing the Entity definitions and tries to map each entity to a DbObjectSchema instance. This process involves determining the correct type for each class field and its configuration at the database level. An exception will be thrown if it's not possible to determine the field type.
  • Constructor Details

    • DbAdmin

      public DbAdmin(@Autowired jakarta.persistence.EntityManager entityManager, @Autowired DbAdminProperties properties)
      Builds the DbAdmin instance by scanning the `@Entity` beans and loading the schemas.
      Parameters:
      entityManager - the entity manager
      properties - the configuration properties
  • Method Details

    • getVersion

      public String getVersion()
      Returns the current version
      Returns:
    • getSchemas

      public List<DbObjectSchema> getSchemas()
      Returns all the loaded schemas (i.e. entity classes)
      Returns:
      the list of loaded schemas from the `@Entity` classes
    • findSchemaByClassName

      public DbObjectSchema findSchemaByClassName(String className)
      Finds a schema by its full class name
      Parameters:
      className - qualified class name
      Returns:
      the schema with this class name
      Throws:
      DbAdminException - if corresponding schema not found
    • findSchemaByTableName

      public DbObjectSchema findSchemaByTableName(String tableName)
      Finds a schema by its table name
      Parameters:
      tableName - the table name on the database
      Returns:
      the schema with this table name
      Throws:
      DbAdminException - if corresponding schema not found
    • findSchemaByClass

      public DbObjectSchema findSchemaByClass(Class<?> klass)
      Finds a schema by its class object
      Parameters:
      klass - the `@Entity` class you want to find the schema for
      Returns:
      the schema for the `@Entity` class
      Throws:
      DbAdminException - if corresponding schema not found