Class DbAdminRepository

java.lang.Object
tech.ailef.dbadmin.external.dbmapping.DbAdminRepository

@Component public class DbAdminRepository extends Object
Implements the basic CRUD operations (and some more)
  • Constructor Details

    • DbAdminRepository

      public DbAdminRepository(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
  • Method Details

    • findById

      public Optional<DbObject> findById(DbObjectSchema schema, Object id)
      Find an object by ID
      Parameters:
      schema - the schema where to look
      id - the primary key value
      Returns:
      an optional with the object with the specified primary key value
    • count

      public long count(DbObjectSchema schema)
    • count

      public long count(DbObjectSchema schema, String query, Set<QueryFilter> queryFilters)
      Counts the elements that match the fuzzy search
      Parameters:
      schema -
      query -
      Returns:
    • findAll

      public PaginatedResult<DbObject> findAll(DbObjectSchema schema, int page, int pageSize, String sortKey, String sortOrder)
      Find all the objects in the schema. Only returns a single page of results based on the input parameters.
      Parameters:
      schema -
      page -
      pageSize -
      sortKey -
      sortOrder -
      Returns:
    • update

      @Transactional("transactionManager") public void update(DbObjectSchema schema, Map<String,String> params, Map<String,org.springframework.web.multipart.MultipartFile> files)
      Update an existing object with new values
      Parameters:
      schema -
      params -
    • attachManyToMany

      @Transactional("transactionManager") public void attachManyToMany(DbObjectSchema schema, Object id, Map<String,List<String>> params)
    • create

      public Object create(DbObjectSchema schema, Map<String,String> values, Map<String,org.springframework.web.multipart.MultipartFile> files, String primaryKey)
      Create a new object with the specific primary key and values, returns the primary key of the created object
      Parameters:
      schema -
      values -
      primaryKey -
    • search

      public PaginatedResult<DbObject> search(DbObjectSchema schema, String query, int page, int pageSize, String sortKey, String sortOrder, Set<QueryFilter> queryFilters)
      Fuzzy search on primary key value and display name
      Parameters:
      schema -
      query -
      Returns:
    • search

      public List<DbObject> search(DbObjectSchema schema, String query)
      Fuzzy search on primary key value and display name
      Parameters:
      schema -
      query -
      Returns:
    • delete

      @Transactional("transactionManager") public void delete(DbObjectSchema schema, String id)
      Delete a specific object
      Parameters:
      schema -
      id -