简体   繁体   中英

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

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;

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM