views:

276

answers:

1

I've been enjoying Hibernate's "yes_no" notation for a while now. I use it a lot on active fields like so:

@Column(name = "active")
@Type(type = "true_false")
public boolean getActive() {
    return active;
}

public void setActive(boolean active) {
    this.active = active;
}

Recently I added a new field called processable, to a different object, like so:

@Column(name = "processable")
@Type(type = "true_false")
public void setProcessable(boolean processable) {
    this.processable = processable;
}

public boolean getProcessable() {
    return processable;
}

When I compile and hibernate builds my database in MySQL, active still shows up as a char but processable is an int. Did I miss something? Do I have a limit on how many char booleans I'm allowed?

+3  A: 

I'm pretty sure that the annotation needs to be on the getter or the property itself and not the setter.

@Column(name = "processable")
@Type(type = "true_false")
    public boolean getProcessable() {
    return processable;
}
zmf
wow, that was a close one. aaaaalmost answered my own :) .
Stephano
i ran a quick search to see if i could find the source for the annotation and shed a bit more light on *why* that is, i didn't immediately find anything so i moved on.
zmf
np. I'm guessing it just assumes it has read access under the annotation. If not, it just sees boolean and makes an int. I guess this makes sense. Oh if only there was a hibernate annotation compiler :) .
Stephano