2

I've got an entity with a few properties that gets used a lot in my Hibernate/GWT app. For the most part, everything works fine, but Hibernate refuses to load one of the properties. It doesn't appear in the query, despite being annotated correctly in the entity.

The relevant portion of the entity:

@Column(name="HasSubSlots")
@Type(type="yes_no")
public boolean hasSubSlotSupport() {
   return hasSubSlotSupport;
}

And the generated SQL query:

Hibernate: 
    /* load entities.DeviceModel */ select
        devicemode0_.DevModel as DevModel1_0_,
        devicemode0_.InvModelName as InvModel2_1_0_ 
    from
        DeviceModels devicemode0_ 
    where
        devicemode0_.DevModel=?

Despite the fact that I refer to that property, it's never loaded, lazily or not, and the getter always returns false. Any ideas on how I can dig deeper into this, or what might be wrong?

1 Answer 1

3

I think it's the method name. It needs to start with is or get to conform to the JavaBeans spec and be picked up by hibernate.

@Column(name="HasSubSlots")
@Type(type="yes_no")
public boolean isSubSlotSupport() {
   return hasSubSlotSupport;
}
Sign up to request clarification or add additional context in comments.

4 Comments

I thought "isSubSlot" would be permissible under the Java Beans spec.
Huh. It'd be a poor name for the method, seeing as isSubSlot seems to me to be asking "is this a sub-slot?", but I'll try it with isSubSlotSupported, which is marginal. Worse than hasSubSlotSupport, but if it works, it works. Thanks for the tip.
You can also use getHasSubSlotSupport() if you would prefer.
Yep, and you were correct--as soon as I changed it to has, Hibernate picked it up. Thanks!

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.