Reputation: 49
I need to do some logic before the value is set from the db with mybatis, however, my list field always has size=0
i really need help, if someone knows please help me, I'm so appreciative
Upvotes: 0
Views: 572
Reputation: 991
MyBatis is calling your setter. But it works differently than you might be thinking.
This is the way it works - MyBatis will create an empty list and set it in your POJO. Then, for each row, MyBatis will call getRoleList().add()
to fill out the list row by row. MyBatis does not create an internal list of values and then call setRoleList()
with a fully populated list.
It is best to use MyBatis objects as simple POJOs. Any other processing should be completed after the objects are returned from MyBatis.
Upvotes: 1