Hibernate. PSQLException: bad value for type int : admin Hibernate. PSQLException: bad value for type int : admin database database

Hibernate. PSQLException: bad value for type int : admin


Finally I found the error!

The error message that Hibernate was returning to me was "bad value for type int: admin", but that was not the problem. This message was completely crazy in relation to the issue. The real problem was that in the database my primary key (pk_role) is a VARCHAR type, but in my entity I put as an INTEGER type.

After Vlad try to help me supposing the version of the jdbc driver, I put the configuration exactly equal to other project I have working pretty well and the error was the same, so I knew that the error was in my own code, for sure.


If you have a separate database schema, just change the column type to boolean:

ALTER TABLE role ALTER COLUMN admin TYPE boolean default false;ALTER TABLE role  MODIFY admin NOT NULL;

and then the mapping is as simple as this:

@Column(name = "admin", nullable = false)private boolean admin = false;