Package tech.ailef.dbadmin.external
Class DbAdmin
java.lang.Object
tech.ailef.dbadmin.external.DbAdmin
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 Summary
ConstructorsConstructorDescriptionDbAdmin
(jakarta.persistence.EntityManager entityManager, DbAdminProperties properties) Builds the DbAdmin instance by scanning the `@Entity` beans and loading the schemas. -
Method Summary
Modifier and TypeMethodDescriptionfindSchemaByClass
(Class<?> klass) Finds a schema by its class objectfindSchemaByClassName
(String className) Finds a schema by its full class namefindSchemaByTableName
(String tableName) Finds a schema by its table nameReturns all the loaded schemas (i.e.
-
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 managerproperties
- the configuration properties
-
-
Method Details
-
getSchemas
Returns all the loaded schemas (i.e. entity classes)- Returns:
- the list of loaded schemas from the `@Entity` classes
-
findSchemaByClassName
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
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
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
-