Philipp Sander
Philipp Sander

Reputation: 10249

Boolean field is always true

My field looks like this:

@Column(columnDefinition = "Number(1,0) default '1'")
protected Boolean developersVisible;

When i get the object from the database, the value is always true. No matter whats in the database (null, 0 , 1)

I'm using a Oracle Database

Solved!

I did not commit when i changed the values via the sqldeveloper

I accepted Óscars answer because it was really helpful

Upvotes: 2

Views: 2018

Answers (2)

V G
V G

Reputation: 19002

Have you tried to use another column definition, like a CHAR? See this post for details.

Upvotes: 0

Óscar López
Óscar López

Reputation: 235994

Don't use the columnDefinition attribute in this case, it's not necessary and it might be messing with the mapping of the field. And the default 1 part explains why you're always getting a true value. Try this:

@Column
protected Boolean developersVisible = Boolean.TRUE;

Upvotes: 4

Related Questions