Skip to content

Commit

Permalink
Use Charset in HibernateOrmConfig and default to UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed May 26, 2020
1 parent 3f07c19 commit f594dd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.hibernate.orm.deployment;

import java.nio.charset.Charset;
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -219,6 +220,8 @@ public boolean isAnyPropertySet() {
@ConfigGroup
public static class HibernateOrmConfigDatabase {

private static final String DEFAULT_CHARSET = "UTF-8";

/**
* Select whether the database schema is generated or not.
*
Expand Down Expand Up @@ -249,9 +252,11 @@ public static class HibernateOrmConfigDatabase {

/**
* The charset of the database.
* <p>
* Used for DDL generation and also for the SQL import scripts.
*/
@ConfigItem
public Optional<String> charset;
@ConfigItem(defaultValue = "UTF-8")
public Charset charset;

/**
* Whether Hibernate should quote all identifiers.
Expand All @@ -262,7 +267,7 @@ public static class HibernateOrmConfigDatabase {
public boolean isAnyPropertySet() {
return !"none".equals(generation) || defaultCatalog.isPresent() || defaultSchema.isPresent()
|| generationHaltOnError
|| charset.isPresent()
|| !DEFAULT_CHARSET.equals(charset.name())
|| globallyQuotedIdentifiers;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,9 @@ private void handleHibernateORMWithNoPersistenceXml(
desc.getProperties().setProperty(AvailableSettings.HBM2DDL_HALT_ON_ERROR, "true");
}

hibernateConfig.database.charset.ifPresent(
charset -> desc.getProperties().setProperty(AvailableSettings.HBM2DDL_CHARSET_NAME, charset));
//charset
desc.getProperties().setProperty(AvailableSettings.HBM2DDL_CHARSET_NAME,
hibernateConfig.database.charset.name());

hibernateConfig.database.defaultCatalog.ifPresent(
catalog -> desc.getProperties().setProperty(AvailableSettings.DEFAULT_CATALOG, catalog));
Expand Down

0 comments on commit f594dd6

Please sign in to comment.