Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideD committed Nov 28, 2024
1 parent bd0f82d commit d051b7a
Show file tree
Hide file tree
Showing 17 changed files with 602 additions and 283 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
*/
package org.hibernate.reactive.adaptor.impl;

import io.vertx.core.buffer.Buffer;

import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -39,12 +34,23 @@
import java.util.Calendar;
import java.util.function.Function;

import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.reactive.logging.impl.Log;

import io.vertx.core.buffer.Buffer;

import static java.lang.invoke.MethodHandles.lookup;
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;

/**
* Collects parameter bindings from Hibernate core code
* that expects a JDBC {@link PreparedStatement}.
*/
public class PreparedStatementAdaptor implements PreparedStatement {

private static final Log LOG = make( Log.class, lookup() );

@FunctionalInterface
public interface Binder {
void bind(PreparedStatement statement) throws SQLException;
Expand Down Expand Up @@ -315,7 +321,7 @@ public void setNClob(int parameterIndex, Reader reader, long length) {

@Override
public void setSQLXML(int parameterIndex, SQLXML xmlObject) {
throw new UnsupportedOperationException();
throw LOG.unsupportedXmlType();
}

@Override
Expand Down Expand Up @@ -540,7 +546,7 @@ public int[] executeBatch() {

@Override
public Connection getConnection() {
throw new UnsupportedOperationException();
throw LOG.unexpectedConnectionRequest();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import org.hibernate.engine.jdbc.proxy.BlobProxy;
import org.hibernate.engine.jdbc.proxy.ClobProxy;
import org.hibernate.reactive.logging.impl.Log;
import org.hibernate.type.descriptor.jdbc.JdbcType;

import io.vertx.core.buffer.Buffer;
Expand All @@ -48,15 +49,19 @@
import io.vertx.sqlclient.desc.ColumnDescriptor;
import io.vertx.sqlclient.impl.RowBase;

import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Collections.emptyList;
import static java.util.Objects.requireNonNull;
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;

/**
* An adaptor that allows Hibernate core code which expects a JDBC
* {@code ResultSet} to read values from Vert.x's {@code RowSet}.
*/
public class ResultSetAdaptor implements ResultSet {

private static final Log LOG = make( Log.class, lookup() );

private final Iterator<? extends Row> iterator;

private final List<ColumnDescriptor> columnDescriptors;
Expand Down Expand Up @@ -866,12 +871,12 @@ public NClob getNClob(String columnLabel) {

@Override
public SQLXML getSQLXML(int columnIndex) {
throw new UnsupportedOperationException();
throw LOG.unsupportedXmlType();
}

@Override
public SQLXML getSQLXML(String columnLabel) {
throw new UnsupportedOperationException();
throw LOG.unsupportedXmlType();
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ public interface Log extends BasicLogger {
@Message(id = 80, value = "No results were returned by the query (you can try running it with '.executeUpdate()'): %1$s")
HibernateException noResultException(String sql);

@Message(id = 81, value = "The Vert.x SQL client doesn't support the SQL XML data type. If it's the mapping of an array, you can also try setting the property `hibernate.type.preferred_array_jdbc_type`")
HibernateException unsupportedXmlType();

@Message(id = 83, value = "Unexpected request of a non reactive connection")
HibernateException unexpectedConnectionRequest();

// Same method that exists in CoreMessageLogger
@LogMessage(level = WARN)
@Message(id = 104, value = "firstResult/maxResults specified with collection fetch; applying in memory!" )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.reactive.metamodel.mapping.internal;

import java.util.Map;

import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.spi.CacheImplementor;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.generator.Generator;
import org.hibernate.mapping.GeneratorSettings;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
import org.hibernate.reactive.tuple.entity.ReactiveEntityMetamodel;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
import org.hibernate.type.spi.TypeConfiguration;

public class ReactiveRuntimeModelCreationContext implements RuntimeModelCreationContext {

private final RuntimeModelCreationContext delegate;

public ReactiveRuntimeModelCreationContext(RuntimeModelCreationContext delegate) {
this.delegate = delegate;
}

@Override
public EntityMetamodel createEntityMetamodel(PersistentClass persistentClass, EntityPersister persister) {
return new ReactiveEntityMetamodel( persistentClass, persister, delegate );
}

@Override
public SessionFactoryImplementor getSessionFactory() {
return delegate.getSessionFactory();
}

@Override
public BootstrapContext getBootstrapContext() {
return delegate.getBootstrapContext();
}

@Override
public MetadataImplementor getBootModel() {
return delegate.getBootModel();
}

@Override
public MappingMetamodelImplementor getDomainModel() {
return delegate.getDomainModel();
}

@Override
public TypeConfiguration getTypeConfiguration() {
return delegate.getTypeConfiguration();
}

@Override
public JavaTypeRegistry getJavaTypeRegistry() {
return delegate.getJavaTypeRegistry();
}

@Override
public MetadataImplementor getMetadata() {
return delegate.getMetadata();
}

@Override
public SqmFunctionRegistry getFunctionRegistry() {
return delegate.getFunctionRegistry();
}

@Override
public Map<String, Object> getSettings() {
return delegate.getSettings();
}

@Override
public Dialect getDialect() {
return delegate.getDialect();
}

@Override
public CacheImplementor getCache() {
return delegate.getCache();
}

@Override
public SessionFactoryOptions getSessionFactoryOptions() {
return delegate.getSessionFactoryOptions();
}

@Override
public JdbcServices getJdbcServices() {
return delegate.getJdbcServices();
}

@Override
public SqlStringGenerationContext getSqlStringGenerationContext() {
return delegate.getSqlStringGenerationContext();
}

@Override
public ServiceRegistry getServiceRegistry() {
return delegate.getServiceRegistry();
}

@Override
public Map<String, Generator> getGenerators() {
return delegate.getGenerators();
}

@Override
public GeneratorSettings getGeneratorSettings() {
return delegate.getGeneratorSettings();
}
}
Loading

0 comments on commit d051b7a

Please sign in to comment.