Skip to content

Commit

Permalink
Register the PostgreSQLGuavaRangeType only if Guava Range is availabl…
Browse files Browse the repository at this point in the history
…e on the classpath #421
  • Loading branch information
vladmihalcea committed Apr 10, 2022
1 parent bed3960 commit 434d28c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Expand Up @@ -8,6 +8,7 @@
import com.vladmihalcea.hibernate.type.json.*;
import com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType;
import com.vladmihalcea.hibernate.type.range.guava.PostgreSQLGuavaRangeType;
import com.vladmihalcea.hibernate.util.ReflectionUtils;
import org.hibernate.boot.model.TypeContributions;
import org.hibernate.boot.model.TypeContributor;
import org.hibernate.dialect.*;
Expand Down Expand Up @@ -50,7 +51,10 @@ public void contribute(TypeContributions typeContributions, ServiceRegistry serv
typeContributions.contributeType(PostgreSQLHStoreType.INSTANCE);
typeContributions.contributeType(PostgreSQLInetType.INSTANCE);
typeContributions.contributeType(PostgreSQLRangeType.INSTANCE);
typeContributions.contributeType(PostgreSQLGuavaRangeType.INSTANCE);

if(ReflectionUtils.getClassOrNull("com.google.common.collect.Range") != null) {
typeContributions.contributeType(PostgreSQLGuavaRangeType.INSTANCE);
}
} else if(dialect instanceof MySQLDialect) {
/* JSON */
typeContributions.contributeType(JsonStringType.INSTANCE);
Expand Down
Expand Up @@ -9,6 +9,7 @@
import com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType;
import com.vladmihalcea.hibernate.type.range.guava.PostgreSQLGuavaRangeType;
import com.vladmihalcea.hibernate.type.search.PostgreSQLTSVectorType;
import com.vladmihalcea.hibernate.util.ReflectionUtils;
import org.hibernate.boot.model.TypeContributions;
import org.hibernate.boot.model.TypeContributor;
import org.hibernate.dialect.*;
Expand Down Expand Up @@ -58,7 +59,10 @@ public void contribute(TypeContributions typeContributions, ServiceRegistry serv
typeContributions.contributeType(PostgreSQLHStoreType.INSTANCE);
typeContributions.contributeType(PostgreSQLInetType.INSTANCE);
typeContributions.contributeType(PostgreSQLRangeType.INSTANCE);
typeContributions.contributeType(PostgreSQLGuavaRangeType.INSTANCE);

if(ReflectionUtils.getClassOrNull("com.google.common.collect.Range") != null) {
typeContributions.contributeType(PostgreSQLGuavaRangeType.INSTANCE);
}
} else if(dialect instanceof MySQLDialect) {
/* JSON */
typeContributions.contributeType(JsonStringType.INSTANCE);
Expand Down
Expand Up @@ -9,6 +9,7 @@
import com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType;
import com.vladmihalcea.hibernate.type.range.guava.PostgreSQLGuavaRangeType;
import com.vladmihalcea.hibernate.type.search.PostgreSQLTSVectorType;
import com.vladmihalcea.hibernate.util.ReflectionUtils;
import org.hibernate.boot.model.TypeContributions;
import org.hibernate.boot.model.TypeContributor;
import org.hibernate.dialect.*;
Expand Down Expand Up @@ -58,7 +59,10 @@ public void contribute(TypeContributions typeContributions, ServiceRegistry serv
typeContributions.contributeType(PostgreSQLHStoreType.INSTANCE);
typeContributions.contributeType(PostgreSQLInetType.INSTANCE);
typeContributions.contributeType(PostgreSQLRangeType.INSTANCE);
typeContributions.contributeType(PostgreSQLGuavaRangeType.INSTANCE);

if(ReflectionUtils.getClassOrNull("com.google.common.collect.Range") != null) {
typeContributions.contributeType(PostgreSQLGuavaRangeType.INSTANCE);
}
} else if(dialect instanceof MySQLDialect) {
/* JSON */
typeContributions.contributeType(JsonStringType.INSTANCE);
Expand Down
Expand Up @@ -9,6 +9,7 @@
import com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType;
import com.vladmihalcea.hibernate.type.range.guava.PostgreSQLGuavaRangeType;
import com.vladmihalcea.hibernate.type.search.PostgreSQLTSVectorType;
import com.vladmihalcea.hibernate.util.ReflectionUtils;
import org.hibernate.boot.model.TypeContributions;
import org.hibernate.boot.model.TypeContributor;
import org.hibernate.cfg.AvailableSettings;
Expand Down Expand Up @@ -63,7 +64,10 @@ public void contribute(TypeContributions typeContributions, ServiceRegistry serv
typeContributions.contributeType(PostgreSQLHStoreType.INSTANCE);
typeContributions.contributeType(PostgreSQLInetType.INSTANCE);
typeContributions.contributeType(PostgreSQLRangeType.INSTANCE);
typeContributions.contributeType(PostgreSQLGuavaRangeType.INSTANCE);

if(ReflectionUtils.getClassOrNull("com.google.common.collect.Range") != null) {
typeContributions.contributeType(PostgreSQLGuavaRangeType.INSTANCE);
}
} else if(dialect instanceof MySQLDialect) {
/* JSON */
typeContributions.contributeType(JsonStringType.INSTANCE);
Expand Down

0 comments on commit 434d28c

Please sign in to comment.