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 25, 2020
1 parent d75cf1e commit a957a10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 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 @@ -250,8 +253,8 @@ public static class HibernateOrmConfigDatabase {
/**
* The charset of the database.
*/
@ConfigItem
public Optional<String> charset;
@ConfigItem(defaultValue = "UTF-8")
public Optional<Charset> charset;

/**
* Whether Hibernate should quote all identifiers.
Expand All @@ -262,7 +265,7 @@ public static class HibernateOrmConfigDatabase {
public boolean isAnyPropertySet() {
return !"none".equals(generation) || defaultCatalog.isPresent() || defaultSchema.isPresent()
|| generationHaltOnError
|| charset.isPresent()
|| (charset.isPresent() && !DEFAULT_CHARSET.equals(charset.get().name()))
|| globallyQuotedIdentifiers;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ private void handleHibernateORMWithNoPersistenceXml(
}

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

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

0 comments on commit a957a10

Please sign in to comment.