Skip to content

Commit

Permalink
HHH-17295 Change which constructor is looked-up in DialectContext tes…
Browse files Browse the repository at this point in the history
…t utils
  • Loading branch information
marko-bekhta authored and beikov committed Oct 9, 2023
1 parent 4bf9bfa commit 30241bb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;

import static org.assertj.core.api.Assertions.assertThat;

import org.hibernate.testing.orm.junit.DialectContext;
import org.junit.Test;

public class DialectContextTest {

@Test
public void smoke() {
Dialect current = DialectContext.getDialect();
assertThat( current ).isNotNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.dialect.spi.DatabaseMetaDataDialectResolutionInfoAdapter;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.internal.util.ReflectHelper;

/**
Expand All @@ -33,13 +31,13 @@ static void init() {
}
try {
final Class<? extends Dialect> dialectClass = ReflectHelper.classForName( dialectName );
final Constructor<? extends Dialect> constructor = dialectClass.getConstructor( DialectResolutionInfo.class );
final Constructor<? extends Dialect> constructor = dialectClass.getConstructor();
Driver driver = (Driver) Class.forName( properties.getProperty( Environment.DRIVER ) ).newInstance();
Properties props = new Properties();
props.setProperty( "user", properties.getProperty( Environment.USER ) );
props.setProperty( "password", properties.getProperty( Environment.PASS ) );
try (Connection connection = driver.connect( properties.getProperty( Environment.URL ), props )) {
dialect = constructor.newInstance( new DatabaseMetaDataDialectResolutionInfoAdapter( connection.getMetaData() ) );
dialect = constructor.newInstance();
}
}
catch (ClassNotFoundException cnfe) {
Expand Down

0 comments on commit 30241bb

Please sign in to comment.