How to make Hibernate ignore a method?

前端 未结 3 1582
再見小時候
再見小時候 2021-01-03 22:09

This question is essentially the opposite of this one.

I have a method like so:

public boolean isVacant() {
    return getEmployeeNum() != null &         


        
3条回答
  •  走了就别回头了
    2021-01-03 22:47

    Many frameworks (like Hibernate and Drools) are smart enough understand that Boolean variables need to be accessed by "is" instead of "get". But they don't always understand perfectly, and that is when "interesting" problems can develop. Or, worse yet, the different frameworks interpret the methods slightly differently, and they are supposed to work together.

    BTW, the @Transient solution is not guaranteed to solve all your problems. Most notably, say that you are adding it to a toString() that returns a huge and complex object. You might be getting a stack overflow not because the method is huge and complex, or even because all the sub-obejcts have their own toString() methods, but because your structure has circular structures. That is what causes the stack overflows.

提交回复
热议问题