On Tue, Jul 3, 2018 at 5:11 AM Yoann Rodiere <yo...@hibernate.org> wrote:
> 2) This is easily handled by the providers, if they wish. They would >> simply map any undefined regions/caches to a pre-defined one (probably >> after warning the user). Keep in mind that region != cache. A provider >> might map multiple region names to a single cache. That was always the >> case, but every provider mapped region <-> cache as 1-1 - the new API >> makes >> this much more clear. > > > Just to clarify: this would require cache implementors to provide their > own region factory, and in that case we all agree they can do whatever they > want, which is nice. > > The problem is more with the built-in Ehcache and JCache region factories. > Our built-in region factories call getCache(String), and if it returns > null, they throw an exception. So the cache implementors do not have an > easy way to auto-create a cache using some internal, default configuration: > they would have to do that in the getCache(String) method, and it's > arguably not something you want to do in a method with such a name, > especially considering it's exposed to other clients than just Hibernate > ORM. And I'm not sure the JCache specification even allows that. > > Ideally we'd like Ehcache/JCache to expose some getOrCreate(String) > method, and decide for themselves whether to throw an exception or not, but > well... they don't. Which explains the suggestion to handle the "default" > logic on our end. > Not sure exactly what you expect this to return - that's the problem. It would need to return a `net.sf.ehcache.Cache` or a `javax.cache.Cache` or a ... So I think you need to split this into a discussion about Ehcache and one about JCache. For Ehcache... whatever. As I keep saying, that provider is based on Ehcache 2 which the Ehcache team hasn't supported for years now. People really should not be using that one. If you want to revert that one, that's fine For JCache, as I have already said, I am fine with adding a setting here to allow on-the-fly creations. On-the-fly creations are a terrible idea, but people can chose that option if they wish. Just make sure that any logging here (especially the "we are creating an on-the-fly Cache for you") happens through `org.hibernate.cache.spi.SecondLevelCacheLogger` _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev