The encoder can't retrieve values of type TreeNode<T>, it can only get values of type T.
It seems that DefaultTreeModel is optimised for session persistence. If you'd prefer to load on demand, you might want to override getById() to lookup all node properties from the database