Skip to content

Commit

Permalink
✨ feat(AbstractDatabase.java, BaseEntity.java, `AbstractEntity.ja…
Browse files Browse the repository at this point in the history
…va`): Replace "query" with "from" for R2DBC operations and entity methods.

This commit updates terminology from "query" to "from" in method names, parameters, and comments to better reflect the nature of R2DBC operations.
  • Loading branch information
vnobo committed Dec 27, 2024
1 parent b33d871 commit 0dd86a1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public abstract class AbstractDatabase extends AbstractService {

/**
* The R2dbcEntityTemplate instance used for executing reactive database operations.
* This template facilitates interaction with the database, including query execution,
* This template facilitates interaction with the database, including from execution,
* entity conversion, and transaction management specifically tailored for R2DBC (Reactive Relational Database Connectivity).
*/
protected R2dbcEntityTemplate entityTemplate;
Expand All @@ -53,21 +53,21 @@ public abstract class AbstractDatabase extends AbstractService {

/**
* The R2DBC Converter instance used for converting between R2DBC Data types and domain-specific objects.
* This converter plays a crucial role in mapping query results to entity classes and vice versa,
* This converter plays a crucial role in mapping from results to entity classes and vice versa,
* facilitating seamless interaction with the R2DBC database through the R2dbcEntityTemplate.
*/
protected R2dbcConverter r2dbcConverter;

/**
* Executes a database query with caching functionality.
* It takes a cache key, a query object, and an entity class type to perform the operation.
* Executes a database from with caching functionality.
* It takes a cache key, a from object, and an entity class type to perform the operation.
* The results are cached for future queries with the same key.
*
* @param <T> The type of entities expected as query results.
* @param <T> The type of entities expected as from results.
* @param key The unique identifier used as a cache key. Determines the cache entry for storing/retrieving results.
* @param query The query object defining the SQL query and its potential parameters.
* @param query The from object defining the SQL from and its potential parameters.
* @param entityClass The class of the entity that each row in the result set will be mapped to.
* @return A {@link Flux} emitting the query results, potentially from cache if previously stored.
* @return A {@link Flux} emitting the from results, potentially from cache if previously stored.
*/
protected <T> Flux<T> queryWithCache(Object key, Query query, Class<T> entityClass) {
Flux<T> source = this.entityTemplate.select(query, entityClass);
Expand All @@ -76,17 +76,17 @@ protected <T> Flux<T> queryWithCache(Object key, Query query, Class<T> entityCla
}

/**
* Executes a SQL query with caching capability. It binds provided parameters to the SQL query,
* Executes a SQL from with caching capability. It binds provided parameters to the SQL from,
* maps the result set to entities of the specified class, applies user auditor serialization,
* and utilizes a cache to store query results for subsequent identical queries.
* and utilizes a cache to store from results for subsequent identical queries.
*
* @param <T> The type of entities the SQL query results will be mapped to.
* @param <T> The type of entities the SQL from results will be mapped to.
* @param key The cache key used to identify the cached data. This should uniquely represent
* the query and its parameters.
* @param sql The SQL query string to be executed.
* @param bindParams A map containing named parameter bindings for the SQL query.
* the from and its parameters.
* @param sql The SQL from string to be executed.
* @param bindParams A map containing named parameter bindings for the SQL from.
* @param entityClass The class of the entity that each row in the result set will be converted into.
* @return A {@link Flux} emitting the entities resulting from the query, potentially from the cache.
* @return A {@link Flux} emitting the entities resulting from the from, potentially from the cache.
*/
protected <T> Flux<T> queryWithCache(Object key, String sql,
Map<String, Object> bindParams, Class<T> entityClass) {
Expand All @@ -100,7 +100,7 @@ protected <T> Flux<T> queryWithCache(Object key, String sql,
}

/**
* Executes a Flux-based database query with caching functionality.
* Executes a Flux-based database from with caching functionality.
* It enhances the source Flux by caching its emissions under a specified key.
* If the cache contains data for the key, it returns the cached data immediately.
* Otherwise, it executes the source Flux, caches the results, and then emits them.
Expand All @@ -122,14 +122,14 @@ protected <T> Flux<T> queryWithCache(Object key, Flux<T> sourceFlux) {
}

/**
* Counts entities with caching support based on the provided key, query, and entity class.
* Counts entities with caching support based on the provided key, from, and entity class.
* This method enhances entity counting by storing the count result in a cache,
* allowing subsequent calls with the same key to retrieve the count directly from the cache
* rather than executing the query again.
* rather than executing the from again.
*
* @param <T> The type of entities for which the count is to be performed.
* @param key A unique identifier used as a cache key. Determines the cached count's retrieval.
* @param query The query object defining the criteria for counting entities.
* @param query The from object defining the criteria for counting entities.
* @param entityClass The class of the entities being counted.
* @return A {@link Mono} emitting the count of entities as a {@link Long}, potentially from cache.
*/
Expand All @@ -139,12 +139,12 @@ protected <T> Mono<Long> countWithCache(Object key, Query query, Class<T> entity
}

/**
* Executes a SQL count query with caching capabilities. It prepares the SQL query with provided bind parameters,
* Executes a SQL count from with caching capabilities. It prepares the SQL from with provided bind parameters,
* creates a Mono source to fetch the count, and then delegates to another method to handle caching logic.
*
* @param key The unique cache key associated with the count query. Used for caching and retrieving results.
* @param sql The SQL count query string to be executed.
* @param bindParams A map containing named parameter placeholders and their respective values for the SQL query.
* @param key The unique cache key associated with the count from. Used for caching and retrieving results.
* @param sql The SQL count from string to be executed.
* @param bindParams A map containing named parameter placeholders and their respective values for the SQL from.
* @return A Mono emitting the count result, potentially fetched from cache or computed from the database.
*/
protected Mono<Long> countWithCache(Object key, String sql, Map<String, Object> bindParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
/**
* This class, AbstractEntity, is a base class for all data entities in the system.
* It provides common fields and methods for all data entities, such as id, code, tenantCode,
* extend, creator, updater, updatedTime, createdTime, query, search, and securityCode.
* extend, creator, updater, updatedTime, createdTime, from, search, and securityCode.
* <p>
* The id field is the unique identifier of the data entity. The code field is the data entity code,
* and the tenantCode field is the data tenant code.
* The extend field is a JsonNode object that represents the data entity extend,Json column.
* The creator field is the data entity create operator, and the updater field is the data entity update operator.
* The updatedTime field is the data entity update time,timestamp column,
* and the createdTime field is the data entity create time, timestamp column.
* The query field is a Map object that supports query for json column,
* The from field is a Map object that supports from for json column,
* and the search field is a String object that supports full text search for tsvector column.
* The securityCode field is a String object that supports security code for sensitive data.
* <p>
Expand Down Expand Up @@ -81,12 +81,7 @@ public abstract class AbstractEntity<T> implements BaseEntity<T> {
protected LocalDateTime createdTime;

/**
* Data full text search entity sort
*/
protected Double rank;

/**
* Support query for json column
* Support from for json column
*/
@Transient
protected Map<String, Object> query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ default String getSearch() {
/**
* postgresql types @code tsvector supports full text search
*
* @param search query tsvector item by string
* @param search from tsvector item by string
*/
default void setSearch(String search) {
}

/**
* Retrieves the default query conditions.
* Returns an immutable empty map, indicating that there are no specific query conditions.
* Retrieves the default from conditions.
* Returns an immutable empty map, indicating that there are no specific from conditions.
*
* @return An immutable map containing the query conditions
* @return An immutable map containing the from conditions
*/
default Map<String, Object> getQuery() {
return Map.of();
}

/**
* Sets the query parameters for the entity.
* Sets the from parameters for the entity.
*
* @param query A map containing the query parameters where the key is a string
* @param query A map containing the from parameters where the key is a string
* representing the parameter name and the value is the parameter value.
*/
default void setQuery(Map<String, Object> query) {
Expand Down Expand Up @@ -100,15 +100,15 @@ default Criteria criteria(Collection<String> skipKeys) {

/**
* Constructs a QueryFragment based on the current entity's properties and conditions,
* allowing for customization of the SQL query by specifying properties to exclude.
* allowing for customization of the SQL from by specifying properties to exclude.
*
* @param skipKeys A collection of String property names indicating which properties
* should not be included in the generated SQL query. This can be useful
* should not be included in the generated SQL from. This can be useful
* for skipping sensitive or unnecessary fields.
* @return A QueryFragment object containing the SQL fragment and parameters necessary
* to form a part of an SQL query. The SQL fragment represents a conditional
* part of the query (e.g., WHERE clause), and the parameters are mapped to
* prevent SQL injection, ensuring secure query execution.
* to form a part of an SQL from. The SQL fragment represents a conditional
* part of the from (e.g., WHERE clause), and the parameters are mapped to
* prevent SQL injection, ensuring secure from execution.
*/
default QueryFragment querySql(Collection<String> skipKeys) {
return QueryHelper.query(this, skipKeys);
Expand Down

0 comments on commit 0dd86a1

Please sign in to comment.