HHH-16444 When logging the selected dialect, log the db version too
The db version used by the dialect makes a huge different on the sql queries used. The log before this commit: ``` INFO SQL dialect [vert.x-worker-thread-0] HHH000400: Using dialect: org.hibernate.dialect.MariaDBDialect ``` The log after this commit: ``` INFO SQL dialect [vert.x-worker-thread-0] HHH000400: Using dialect: org.hibernate.dialect.MariaDBDialect, version: 10.11 ``` I've also updated the HANADialectTestCase because now the error message contains the db version
This commit is contained in:
parent
4eef64f81e
commit
1de4a76008
|
@ -1528,7 +1528,7 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName();
|
||||
return getClass().getName() + ", version: " + getVersion();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -84,4 +84,21 @@ public class SimpleDatabaseVersion implements DatabaseVersion {
|
|||
public int getMicro() {
|
||||
return micro;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder version = new StringBuilder();
|
||||
if ( major != NO_VERSION ) {
|
||||
version.append( major );
|
||||
}
|
||||
if ( minor != NO_VERSION ) {
|
||||
version.append( "." );
|
||||
version.append( minor );
|
||||
if ( micro > 0 ) {
|
||||
version.append( "." );
|
||||
version.append( micro );
|
||||
}
|
||||
}
|
||||
return version.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,10 @@ import jakarta.persistence.GeneratedValue;
|
|||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class HANADialectTestCase extends BaseUnitTestCase {
|
||||
@Test
|
||||
|
@ -42,20 +41,18 @@ public class HANADialectTestCase extends BaseUnitTestCase {
|
|||
() -> new StandardServiceRegistryBuilder()
|
||||
.applySetting( AvailableSettings.DIALECT, HANAColumnStoreDialect.class )
|
||||
.build(),
|
||||
(registryScope) -> {
|
||||
registryScope -> {
|
||||
final StandardServiceRegistry registry = registryScope.getRegistry();
|
||||
final MetadataSources metadataSources = new MetadataSources( registry );
|
||||
metadataSources.addAnnotatedClass( EntityWithIdentity.class );
|
||||
|
||||
try ( SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) metadataSources.buildMetadata().buildSessionFactory() ) {
|
||||
fail( "Should have thrown MappingException!" );
|
||||
}
|
||||
catch (MappingException e) {
|
||||
MatcherAssert.assertThat(
|
||||
e.getMessage(),
|
||||
is( "The INSERT statement for table [EntityWithIdentity] contains no column, and this is not supported by [" + HANAColumnStoreDialect.class.getName() + "]" )
|
||||
);
|
||||
}
|
||||
String errorMessage = assertThrows( MappingException.class, () -> {
|
||||
try ( SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) metadataSources.buildMetadata().buildSessionFactory() ) {
|
||||
// Nothing to do, we expect an exception
|
||||
}
|
||||
} ).getMessage();
|
||||
assertThat( errorMessage )
|
||||
.matches( "The INSERT statement for table \\[EntityWithIdentity\\] contains no column, and this is not supported by \\[" + HANAColumnStoreDialect.class.getName() + ", version: [\\d\\.]+\\]" );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue