Skip to content

Commit 49178e1

Browse files
feat: view index on select from
1 parent d60388b commit 49178e1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

hibernate-dialect/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.5 ##
2+
3+
- Added query hint for view index for "select * from ... where" queries
4+
15
## 0.9.4 ##
26

37
- Fixed the generated bool value

hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/YdbDialect.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public class YdbDialect extends Dialect {
6464

6565
private static final Exporter<ForeignKey> FOREIGN_KEY_EMPTY_EXPORTER = new EmptyExporter<>();
6666
private static final Exporter<Constraint> UNIQUE_KEY_EMPTY_EXPORTER = new EmptyExporter<>();
67-
private static final Pattern QUERY_PATTERN = Pattern.compile("^\\s*(select.+?from\\s+\\w+)(.+where.+)$", Pattern.CASE_INSENSITIVE);
67+
private static final Pattern SELECT_FROM_WHERE_QUERY_PATTERN = Pattern
68+
.compile("^\\s*(select.+?from\\s+\\w+)(.+where.+)$", Pattern.CASE_INSENSITIVE);
6869

6970
public YdbDialect(DialectResolutionInfo dialectResolutionInfo) {
7071
super(dialectResolutionInfo);
@@ -123,7 +124,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
123124

124125
@Override
125126
public String getQueryHintString(String query, String hints) {
126-
Matcher matcher = QUERY_PATTERN.matcher(query);
127+
Matcher matcher = SELECT_FROM_WHERE_QUERY_PATTERN.matcher(query);
127128
if (matcher.matches() && matcher.groupCount() > 1) {
128129
String startToken = matcher.group(1);
129130
String endToken = matcher.group(2);

0 commit comments

Comments
 (0)