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
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.
尝试添加:
@Type(type = "org.hibernate.type.NumericBooleanType")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.