"arguments against a generic jsf object converter with a static weakhashmap" Code Answer


this approach is hacky and memory inefficient.

it's "okay" in a small application, but definitely not in a large application with tens or hundreds of thousands of potential entities around which could be referenced in a f:selectitems. moreover, such a large application has generally a second level entity cache. the weakhashmap becomes then useless and is only effective when an entity is physically removed from the underlying datastore (and thus also from second level entity cache).

it has certainly a "fun" factor, but i'd really not recommend using it in "heavy production".

if you don't want to use an existing solution from an utility library like omnifaces selectitemsconverter as you already found, which is basically completely stateless and doesn't use any dao/service call, then your best bet is to abstract all your entities with a common base interface/class and hook the converter on that instead. this only still requires a dao/service call. this has been fleshed out in detail in this q&a: implement converters for entities with java generics.

By Pallavi Goyal on April 18 2022

Answers related to “arguments against a generic jsf object converter with a static weakhashmap”

Only authorized users can answer the Search term. Please sign in first, or register a free account.