I post a [similar question](https://stackoverflow.com/questions/71576150/) previously, but have opened another question to be more specific as the previous one gave me a solution but I have now encountered another problem.

We have an existing Oracle database that had boolean columns defined like so

```
CREATE TABLE MY_TABLE 
(    
SOME_TABLE_COLUMN NUMBER(1) DEFAULT 0 NOT NULL,
etc..

```

And with the corresponding java field defined like `private boolean someTableColumn;` I've come to understand this is because Oracle does not have a Boolean datatype, but under the hood does the conversion from boolean to integer when inserting data, and the reverse when retriving data.

This has caused an issue when I have been working on migrating our database from Oracle to Postgres. Thanks to answers on my previous question, I have migrated the column type from `NUMBER(1)` to `BOOLEAN`. This has solved the issue with inserting data. However, our codebase uses `JDBCTemplate` and we unfortunately have hundereds of hardcoded queries in the code that make queries like `SELECT * FROM MY_TABLE WHERE TABLE_COLUMN=1`.

When these run against the Postgres DB, I get the following error `ERROR: operator does not exist: boolean = integer`. We have a requirement to have backwards compatability with Oracle, so I can't simply update these queries to replace `1` and `0` with `TRUE` and `FALSE` respectively.

Is there a way I can configure Postgres so it can do a conversion behind the scenes to resolve this? I have looked at casts but I don't really understand the documentation and the examples given don't seem to match my use case. Any help is appreciated.