2

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

1
  • Why do you use smallint if you want a boolean? Commented Apr 1, 2016 at 13:38

2 Answers 2

6

try adding :

@Type(type = "org.hibernate.type.NumericBooleanType")
Sign up to request clarification or add additional context in comments.

Comments

5

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.