v6.0.4 (2025-05-29)
<dependency>
<groupId>net.hasor</groupId>
<artifactId>dbvisitor</artifactId>
<version>6.0.4</version>
</dependency>
Impact
- Queries built with the condition builder
Changes
- [Fixed] When
selectTemplateis configured and the condition builder generates a query without an explicit select list, the SQL now correctly includes theselectTemplate. - [Fixed] OracleDialect now supports
DuplicateKeyStrategy.Update(thanks to ooknight). - [Improved] When the condition builder uses
group bywithout specifying select columns, the builder no longer auto-adds the group by list; it uses*instead. The resulting SQL may not run, but surfaces the issue during development and avoids per-call checks for better performance.
案例:
@Data
@Table("t_sample")
public class Sample {
@Column(name = "id", primary = true)
private Long id;
@Column(selectTemplate = "AsText(point)", // 会生成 select AsText(point) as point
insertTemplate = "GeomFromText(?)", // 会生成 insert ... values (GeomFromText(?))
setValueTemplate = "GeomFromText(?)",// 会生成 update ... set point = GeomFromText(?)
whereColTemplate = "AsText(point)" // 会生成 ... where AsText(point) = ?
)
private String point;
}
---
lambdaQuery.and(qb -> qb.eq(Sample::getPoint, "point(11,11)"))
.queryForList();
---
使用下列语句执行查询
SELECT id , AsText(point) point FROM point_table WHERE ( AsText(point) = ? )
More
selectTemplate is a dbVisitor feature for generating SQL during object mapping. For example, when reading/writing MySQL point columns, the template can inject PointFromText/AsText functions into generated SQL. See SQL templates for details.