What are the Maven dependencies to use hibernate, hibernate annotations, and ehcache?

前端 未结 3 1284
旧时难觅i
旧时难觅i 2021-01-30 23:46

I would like to update my Maven pom.xml with the latest hibernate, hibernate-annotations, and ehcache dependencies.

I read the hibernate download page and the ehcache do

3条回答
  •  再見小時候
    2021-01-31 00:30

    If you really mean the ultimate versions of hibernate-annotations (and not hibernate-entitymanager) and ehcache, then you'll need the following:

    
      ...
      
        
          org.hibernate
          hibernate-core
          3.6.0.Final
        
        
           net.sf.ehcache
           ehcache-core
           2.2.0
       
       ...
      
    
      
        
          repository.jboss.org-public
          JBoss repository
          https://repository.jboss.org/nexus/content/groups/public
        
      
      ...
    
    

    As of Hibernate 3.6, JDK 1.4 support has been dropped and the Hibernate Annotations have been merged back into Core.

    I you meant Hibernate EntityManager, then replace hibernate-core by hibernate-entitymanager in the above snippet.

    Regarding EHCache, ehcache-core should provide everything you need (including implementations of the "new" Hibernate 3.3/3.5 caching SPI with its CacheRegionFactory). So, as documented:

    Setting Ehcache as the Hibernate Second Level Cache

    Hibernate 3.3 and higher

    ATTENTION HIBERNATE 3.2 USERS

    Make sure to note the change to BOTH the property name and value.

    Use:

    
              net.sf.ehcache.hibernate.EhCacheRegionFactory
    

    for instance creation, or

    
              net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
    

    to force Hibernate to use a singleton of Ehcache CacheManager.


    Follow-up: To answer your update:

    sl4j threw errors, which went away by adding (...)

    Well, I can't guess what logging framework you're using, providing the binding of your choice was left as an exercise for the reader :)

    There are many instances of this warning (...)

    I get only one WARNING when running in a non JTA environment. If that's your case (a non JTA environment), I would consider the WARNING as normal. If that's not your case, have a look at the documentation about JTA.

    Additionally, this error makes everything fail

    This is somehow a different question (but it looks like the SessionFactory fails to initialize properly, activate logging to see why) and I suggest to post a new spring specific question.

提交回复
热议问题