Reputation: 73
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
Upvotes: 2
Views: 10757
Reputation: 61
try adding :
@Type(type = "org.hibernate.type.NumericBooleanType")
Upvotes: 5
Reputation: 73528
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.
Upvotes: 5