Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
cf28195
Support Oracle db VECTOR type
n0tl3ss Dec 8, 2025
70359a5
refactor Vector type
n0tl3ss Dec 10, 2025
efd704e
remove gradle properties
n0tl3ss Dec 10, 2025
cd72557
add support for multiple dialects and adds postgres vectors
n0tl3ss Dec 11, 2025
d4913f4
Merge branch '5.0.x' into support-vector-type-oracledb
n0tl3ss Dec 11, 2025
0098291
fix requires
n0tl3ss Dec 11, 2025
8196182
refactor for r2dbc
n0tl3ss Dec 12, 2025
3996937
fix tests
n0tl3ss Dec 12, 2025
683b1dd
fix tests
n0tl3ss Dec 12, 2025
f3268f0
fix impl
n0tl3ss Dec 12, 2025
6180793
fix postgres
n0tl3ss Dec 13, 2025
ab18770
fix postgres
n0tl3ss Dec 13, 2025
e59b8f1
fix test
n0tl3ss Dec 13, 2025
775a883
fix result reader
n0tl3ss Dec 13, 2025
ef095f8
remove extra annotation
n0tl3ss Dec 13, 2025
f700207
remove setup from tests
n0tl3ss Dec 13, 2025
d094e09
improve docs
n0tl3ss Dec 14, 2025
1041e83
improve docs
n0tl3ss Dec 14, 2025
f4eee69
fix tests
n0tl3ss Dec 14, 2025
2e2a76b
fix tests
n0tl3ss Dec 14, 2025
5ab85e7
cleanup
n0tl3ss Dec 15, 2025
15d3fcb
remove mapping
n0tl3ss Dec 15, 2025
c3dab64
fix bugs and duplicate code
n0tl3ss Dec 15, 2025
b68fbf1
fix test and duplication
n0tl3ss Dec 15, 2025
7dc2cb1
add more tests
n0tl3ss Dec 15, 2025
f4e92d2
fix tests
n0tl3ss Dec 15, 2025
210a290
add mysql support for vectors in jdbc
n0tl3ss Dec 17, 2025
90155bf
add improvements
n0tl3ss Dec 18, 2025
f0632e1
Merge branch '5.0.x' into support-vector-type-oracledb
n0tl3ss Dec 18, 2025
6a1dce2
use mysql connector-j instead of mysql-connector-java
n0tl3ss Dec 19, 2025
ce43e09
fix tests
n0tl3ss Dec 19, 2025
36bbe0d
Merge branch '5.0.x' into support-vector-type-oracledb
n0tl3ss Dec 19, 2025
583ce81
remove surplus
n0tl3ss Dec 19, 2025
a2d0174
fix bugs
n0tl3ss Dec 22, 2025
a9681f2
minor fixes
n0tl3ss Dec 22, 2025
7a2567f
minor refactor
n0tl3ss Dec 22, 2025
81b8f95
minor refactor
n0tl3ss Dec 22, 2025
5c752fa
minor cosmetics
n0tl3ss Dec 22, 2025
3eefef0
improve docs
n0tl3ss Dec 23, 2025
b2ed398
add kotlin and groovy examples
n0tl3ss Dec 23, 2025
43983c3
Merge branch '5.0.x' into support-vector-type-oracledb
n0tl3ss Dec 23, 2025
e3b12aa
move to Jspecific
n0tl3ss Dec 23, 2025
314fbc9
add vector indexes
n0tl3ss Dec 25, 2025
a42db6e
try to provide different image because of space on the runner
n0tl3ss Dec 26, 2025
6322b91
add more tests
n0tl3ss Dec 26, 2025
56db57e
try to remove /usr/local/lib/android on start to free more space
n0tl3ss Dec 26, 2025
acad5e0
try to remove /usr/share/dotnet on start to free more space
n0tl3ss Dec 26, 2025
0f4d038
fix OracleVectorSqlIndexDefinitionProvider
n0tl3ss Dec 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
export PATH=$(echo "$PATH" | tr ':' '\n' | grep -v '/usr/lib/jvm' | paste -sd:)
- name: "🗑 Free disk space"
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo apt-get clean
Expand Down
1 change: 1 addition & 0 deletions data-connection-jdbc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ micronaut {
enabled = true
inferClasspath = false
additionalModules.add(KnownModules.JDBC_POSTGRESQL)
additionalModules.add(KnownModules.JDBC_ORACLE_XE)
clientTimeout = 300
version = libs.versions.micronaut.testresources.get()
}
Expand Down
1 change: 1 addition & 0 deletions data-connection-jdbc/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test-resources:
startup-timeout: 300s
image-name: gvenzl/oracle-free:latest-faststart
postgres:
image-name: pgvector/pgvector:pg16
startup-timeout: 300s

micronaut:
Expand Down
2 changes: 1 addition & 1 deletion data-hibernate-reactive/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {
testRuntimeOnly mnSql.vertx.mysql.client

// Needed for test resources
testResourcesService mnSql.mysql.connector.java
testResourcesService mnSql.mysql.connector.j
testResourcesService mnSql.postgresql
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ default Map<String, String> getProperties() {
"jpa.default.properties.hibernate.hbm2ddl.auto", "create-drop",
"jpa.default.reactive", "true",
"jpa.default.properties.hibernate.connection.db-type", "mysql",
"test-resources.containers.mysql.image-name", "mysql:8.4.5"
"test-resources.containers.mysql.image-name", "container-registry.oracle.com/mysql/community-server:latest"
);
}
}
11 changes: 8 additions & 3 deletions data-jdbc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ dependencies {
compileOnly mnRxjava2.micronaut.rxjava2
compileOnly projects.micronautDataHibernateJpa
compileOnly mnSql.ojdbc11
compileOnly mnSql.postgresql
compileOnly mnSql.mysql.connector.j
compileOnly libs.managed.pg.vector

testAnnotationProcessor mn.micronaut.inject.java
testAnnotationProcessor projects.micronautDataProcessor
testAnnotationProcessor mnValidation.micronaut.validation.processor

testImplementation projects.micronautDataTck
testImplementation libs.managed.pg.vector
testImplementation projects.micronautDataProcessor
testImplementation mnRxjava2.micronaut.rxjava2
testImplementation mnReactor.micronaut.reactor
Expand All @@ -44,22 +48,23 @@ dependencies {
testImplementation(mnTestResources.testcontainers.oracle.xe)

testCompileOnly mn.micronaut.inject.groovy
testImplementation mnSql.ojdbc11


testImplementation mnMultitenancy.micronaut.multitenancy

testImplementation mn.micronaut.http.netty
testRuntimeOnly mnSql.micronaut.jdbc.tomcat
testRuntimeOnly mnSql.h2
testRuntimeOnly mnSql.mariadb.java.client
testRuntimeOnly mnSql.ojdbc11
testRuntimeOnly mnSql.mysql.connector.java
testRuntimeOnly mnSql.mysql.connector.j
testRuntimeOnly mnSql.postgresql
testRuntimeOnly mnSql.mssql.jdbc
testRuntimeOnly mn.snakeyaml

testResourcesService mnSql.mariadb.java.client
testResourcesService mnSql.ojdbc11
testResourcesService mnSql.mysql.connector.java
testResourcesService mnSql.mysql.connector.j
testResourcesService mnSql.postgresql
testResourcesService mnSql.mssql.jdbc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import io.micronaut.data.model.query.builder.sql.SqlQueryBuilder;
import io.micronaut.data.model.query.builder.sql.SqlSchemaUtils;
import io.micronaut.data.model.query.builder.sql.validation.SqlTableMappingValidator;
import io.micronaut.data.model.runtime.convert.DefinitionProvider;
import io.micronaut.data.model.runtime.RuntimeEntityRegistry;
import io.micronaut.data.model.schema.sql.SqlTableMapping;
import io.micronaut.data.model.schema.sql.metadata.SqlColumnMetadata;
Expand Down Expand Up @@ -79,19 +80,22 @@ public class SchemaGenerator {
private final JdbcSchemaHandler schemaHandler;
private final Map<Dialect, SqlTableMappingValidator> dialectSqlTableMappingValidatorMap;
private final PropertyPlaceholderResolver propertyPlaceholderResolver;
private final List<DefinitionProvider> definitionProviders;

/**
* Constructors a schema generator for the given configurations.
*
* @param configurations The configurations
* @param schemaHandler The schema handler
* @param sqlTableMappingValidators The list of {@link SqlTableMappingValidator} instances
* @param environment The environment
* @param configurations The configurations
* @param schemaHandler The schema handler
* @param sqlTableMappingValidators The list of {@link SqlTableMappingValidator} instances
* @param environment The environment
* @param definitionProviders Providers of vendor-specific SQL definitions (columns and indexes) used during schema generation
*/
public SchemaGenerator(List<DataJdbcConfiguration> configurations,
JdbcSchemaHandler schemaHandler,
List<SqlTableMappingValidator> sqlTableMappingValidators,
Environment environment) {
Environment environment,
List<DefinitionProvider> definitionProviders) {
this.configurations = configurations == null ? Collections.emptyList() : configurations;
this.schemaHandler = schemaHandler;
this.propertyPlaceholderResolver = environment.getPlaceholderResolver();
Expand All @@ -103,6 +107,7 @@ public SchemaGenerator(List<DataJdbcConfiguration> configurations,
}
dialectSqlTableMappingValidatorMap.put(dialect, sqlTableMappingValidator);
}
this.definitionProviders = definitionProviders == null ? Collections.emptyList() : definitionProviders;
}

/**
Expand Down Expand Up @@ -178,10 +183,11 @@ public void createOrValidateSchema(BeanLocator beanLocator) {
}
}

private static void generate(Connection connection,
DataJdbcConfiguration configuration,
PropertyPlaceholderResolver propertyPlaceholderResolver,
PersistentEntity[] entities) throws SQLException {
@SuppressWarnings("java:S3776")
private void generate(Connection connection,
DataJdbcConfiguration configuration,
PropertyPlaceholderResolver propertyPlaceholderResolver,
PersistentEntity[] entities) throws SQLException {
Dialect dialect = configuration.getDialect();
SqlQueryBuilder builder = new SqlQueryBuilder(dialect);
if (dialect.allowBatch() && configuration.isBatchGenerate()) {
Expand All @@ -201,7 +207,7 @@ private static void generate(Connection connection,
}
}
case CREATE:
String sql = resolveSql(propertyPlaceholderResolver, builder.buildBatchCreateTableStatement(entities));
String sql = resolveSql(propertyPlaceholderResolver, builder.buildBatchCreateTableStatement(definitionProviders, entities));
if (DataSettings.QUERY_LOG.isDebugEnabled()) {
DataSettings.QUERY_LOG.debug("Creating Tables: \n{}", sql);
}
Expand Down Expand Up @@ -234,7 +240,7 @@ private static void generate(Connection connection,
}
}
case CREATE:
String[] sql = builder.buildCreateTableStatements(entities);
String[] sql = builder.buildCreateTableStatements(entities, dialect, definitionProviders);
for (String stmt : sql) {
stmt = resolveSql(propertyPlaceholderResolver, stmt);
if (DataSettings.QUERY_LOG.isDebugEnabled()) {
Expand All @@ -257,10 +263,10 @@ private static void generate(Connection connection,
}
}

private static void validate(Connection connection,
DataJdbcConfiguration configuration,
PersistentEntity[] entities,
Map<Dialect, SqlTableMappingValidator> dialectSqlTableMappingValidatorMap) throws SQLException {
private void validate(Connection connection,
DataJdbcConfiguration configuration,
PersistentEntity[] entities,
Map<Dialect, SqlTableMappingValidator> dialectSqlTableMappingValidatorMap) throws SQLException {
Dialect dialect = configuration.getDialect();
SqlTableMappingValidator sqlTableMappingValidator = dialectSqlTableMappingValidatorMap.get(dialect);
if (sqlTableMappingValidator == null) {
Expand All @@ -270,7 +276,7 @@ private static void validate(Connection connection,
// that represents join and ad-hoc SqlTableMapping for the same entity based on relation mappings (to be removed/skipped)
Map<String, SqlTableMapping> sqlTableMappingByTableName = CollectionUtils.newLinkedHashMap(entities.length);
for (PersistentEntity entity : entities) {
List<SqlTableMapping> sqlTableMappings = SqlSchemaUtils.getSqlTableMappings(entity);
List<SqlTableMapping> sqlTableMappings = SqlSchemaUtils.getSqlTableMappings(definitionProviders, entity, dialect);
for (SqlTableMapping sqlTableMapping : sqlTableMappings) {
String tableName = sqlTableMapping.name();
String tableNameLowerCase = tableName.toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.micronaut.data.jdbc.convert;

import io.micronaut.core.convert.ConversionContext;
import io.micronaut.data.model.runtime.convert.DatabaseTypeConversionContext;

import java.sql.Connection;

Expand All @@ -25,13 +25,12 @@
* @author Denis Stepanov
* @since 3.1
*/
public interface JdbcConversionContext extends ConversionContext {
public interface JdbcConversionContext extends DatabaseTypeConversionContext {

/**
* Provides access to JDBC connection.
*
* @return the connection
*/
Connection getConnection();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.data.jdbc.convert.vendor;

import io.micronaut.core.annotation.Internal;
import io.micronaut.core.convert.ConversionService;
import io.micronaut.data.model.runtime.convert.vector.VectorTypeConverter;
import io.micronaut.data.model.vector.Vector;

@Internal
abstract class AbstractJdbcVectorConverter<T> implements VectorTypeConverter<T> {

private final ConversionService conversionService;

protected AbstractJdbcVectorConverter(ConversionService conversionService) {
this.conversionService = conversionService;
}

@Override
public T convert(Vector vector) {
if (supportedVectorTypes().stream().anyMatch(x -> vector.getClass().isAssignableFrom(x))) {
return conversionService.convert(vector, getPersistedType()).orElse(null);
}
throw new IllegalArgumentException(databaseType() + " does not support " + vector.getClass().getName());
}

@Override
public Vector convert(T object, Class<Vector> targetType) {
if (supportedVectorTypes().stream().anyMatch(targetType::isAssignableFrom)) {
return conversionService.convert(object, targetType).orElse(null);
}
throw new IllegalArgumentException(databaseType() + " does not support " + targetType.getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.data.jdbc.convert.vendor;

import io.micronaut.core.annotation.Internal;
import io.micronaut.context.annotation.Requires;
import io.micronaut.core.convert.ConversionService;
import io.micronaut.data.model.runtime.convert.DatabaseType;
import io.micronaut.data.model.runtime.convert.vector.VectorTypeConverter;
import io.micronaut.data.model.vector.FloatVector;
import io.micronaut.data.model.vector.Vector;
import jakarta.inject.Singleton;

import java.util.List;


/**
* MySQL-specific {@link VectorTypeConverter} that maps {@link Vector} to JDBC binary (byte[]) accepted
* by MySQL HeatWave VECTOR (float32 little-endian, plain concatenation), and back.
*
* Persisted type: {@code byte[]} (float32 LE per element)
*
* Example: (1.0, 2.0, 3.0) -> bytes: 00 00 80 3F 00 00 00 40 00 00 40 40
*
* @author Nemanja Mikic
* @since 5.0.0
*/
@Internal
@Requires(classes = com.mysql.cj.jdbc.Driver.class)
@Singleton
final class MySqlJdbcVectorConverter extends AbstractJdbcVectorConverter<byte[]> {

MySqlJdbcVectorConverter(ConversionService conversionService) {
super(conversionService);
}

@Override
public Class<byte[]> getPersistedType() {
return byte[].class;
}

public List<Class<? extends Vector>> supportedVectorTypes() {
return List.of(Vector.class, FloatVector.class);
}

@Override
public DatabaseType databaseType() {
return DatabaseType.MYSQL;
}
}
Loading
Loading