I have object with boolean field like
@Entity
@Table(name = "USERS")
public class User {
@Id
@GeneratedValue
@Column(name = "ID")
private Integer id;
@Column(name = "ACTIVE")
private Boolean active = true;
}
AND query for creating
CREATE TABLE IF NOT EXISTS USERS(
ID SERIAL PRIMARY KEY,
ACTIVE SMALLINT ,
LOGIN CHAR(255) NOT NULL,
NAME CHAR(255) NOT NULL,
PASSWORD CHAR(255) NOT NULL,
ROLE INTEGER NOT NULL REFERENCES ROLE(ID)
);
When i try to take a user object i have next exception ERROR: operator does not exist: smallint = boolean
try adding :
@Type(type = "org.hibernate.type.NumericBooleanType")
In PostgreSQL, SMALLINT maps to Short and BOOLEAN maps to Boolean (hence the name).
You get to decide whether to change the class or the table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With