# Check condition for BooleanJavaType with Boolean converter

**URL:** <https://discourse.hibernate.org/t/check-condition-for-booleanjavatype-with-boolean-converter/11020>\
**Category:** Hibernate ORM\
**Created:** [February 10, 2025, 8:56am UTC](https://discourse.hibernate.org/t/check-condition-for-booleanjavatype-with-boolean-converter/11020 "2025-02-10T08:56:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bettyboo76](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/bettyboo76/32/3844_2.png) [@bettyboo76](https://discourse.hibernate.org/u/bettyboo76)\
**Post date:** [February 10, 2025, 8:56am UTC](https://discourse.hibernate.org/t/check-condition-for-booleanjavatype-with-boolean-converter/11020/1 "2025-02-10T08:56:45Z")

</div>

Hi,  
I’m using Hibernate in a Spring Boot application. I’m having some issues migrating to version 6.4 due to the presence of Converters, especially with the constraint generation part. Specifically:

1. Why are constraints always generated even if DDL generation is disabled in the configuration?
2. I believe it should be configurable how these check condition constraints are generated. Simply put, my Converter for Boolean and Enum is not deterministic: I want to store obfuscated data in the database, and I don’t want `true` to always have the same value. This conflicts with the way the constraint is generated, as it does not account for this particularity. I believe this should be a behavior that can be disabled.

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [February 10, 2025, 1:45pm UTC](https://discourse.hibernate.org/t/check-condition-for-booleanjavatype-with-boolean-converter/11020/2 "2025-02-10T13:45:50Z")

</div>

You can create a subclass of `BooleanJavaType` and register that via the `@JavaTypeRegistration` annotation to take effect globally. In that subtype, just always return `null` for the `getCheckCondition` method.  
Note though, that a mapping that is not globally homomorphic will make it impossible to use a field of that type in a query.

---

<div class="post-metadata">

**Author:** ![bettyboo76](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/bettyboo76/32/3844_2.png) [@bettyboo76](https://discourse.hibernate.org/u/bettyboo76)\
**Post date:** [February 11, 2025, 12:41pm UTC](https://discourse.hibernate.org/t/check-condition-for-booleanjavatype-with-boolean-converter/11020/3 "2025-02-11T12:41:05Z")

</div>

Hi @beikov ,  
thanks, I confirm that using a custom `BooleanJavaType` with `@JavaTypeRegistration` it works. What initially held me back from this approach is that I can’t understand why Hibernate generates constraints even though I have set `generate-ddl: false` and `ddl-auto: none`. My database already exists, so Hibernate should not be responsible for generating the database script (and consequently, not the check condition either). Why does Hibernate always generate the check conditions?

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [February 11, 2025, 12:53pm UTC](https://discourse.hibernate.org/t/check-condition-for-booleanjavatype-with-boolean-converter/11020/4 "2025-02-11T12:53:27Z")

</div>

What do you mean by “always generate the check condition” exactly? Do you mean the code for generating this DDL fragment is called even though you disabled DDL generation?

---

<div class="post-metadata">

**Author:** ![bettyboo76](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/bettyboo76/32/3844_2.png) [@bettyboo76](https://discourse.hibernate.org/u/bettyboo76)\
**Post date:** [February 11, 2025, 1:29pm UTC](https://discourse.hibernate.org/t/check-condition-for-booleanjavatype-with-boolean-converter/11020/5 "2025-02-11T13:29:42Z")

</div>

Exactly. In my application, Hibernate does not generate the schema; the database is managed by Liquibase. In fact, in the configuration, I have `ddl-auto: none` and `generate-ddl: false`. However, despite this, the `getCheckCondition` method is called for all the entity columns whose field is a Boolean. Since this is a string used exclusively for schema creation, I can’t understand why it is necessary to call the `getCheckCondition` method in this case.

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [February 12, 2025, 1:36pm UTC](https://discourse.hibernate.org/t/check-condition-for-booleanjavatype-with-boolean-converter/11020/6 "2025-02-12T13:36:08Z")

</div>

I guess it’s just “easier” to do that stuff this way. Please create a bug ticket in our [issue tracker](https://hibernate.atlassian.net) and link to this conversation.

---

<div class="post-metadata">

**Author:** ![bettyboo76](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/bettyboo76/32/3844_2.png) [@bettyboo76](https://discourse.hibernate.org/u/bettyboo76)\
**Post date:** [February 12, 2025, 2:01pm UTC](https://discourse.hibernate.org/t/check-condition-for-booleanjavatype-with-boolean-converter/11020/7 "2025-02-12T14:01:16Z")

</div>

Thank you @beikov  
Here the issue: [Jira](https://hibernate.atlassian.net/browse/HHH-19128)
