Announcement Announcement Module
Collapse
No announcement yet.
Hib 3 Entity Caching Strats on LocalSessionFactoryBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hib 3 Entity Caching Strats on LocalSessionFactoryBean

    Do the caching strategies specified in LocalSessionFactoryBean over-ride any caching specifically stated within the HBM.XML files, or do the XML files take precedence?

  • #2
    2nd level caching

    The caching settings for the LocalSessionFactory bean are basically the same as if you had a non-spring managed session factory

    The entity and collection cache strategies settings on the LocalSessionFactory map to the class and collection settings..

    i.e.
    Code:
    <hibernate-configuration>
    
        <session-factory
            name="java&#58;hibernate/SessionFactory">
    
            <!-- properties -->
            . . .
    
            <!-- mapping files -->
            <mapping resource="org/hibernate/auction/Item.hbm.xml"/>
            <mapping resource="org/hibernate/auction/Bid.hbm.xml"/>
    
            <!-- cache settings -->
            <class-cache class="org.hibernate.auction.Item" usage="read-write"/>
            <class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
            <collection-cache class="org.hibernate.auction.Item.bids" usage="read-write"/>
    
        </session-factory>
    
    </hibernate-configuration>

    I am not sure if / why you would mix and match SessionFactory and HBM level configuration... however I would assume it would be an "AND" situation.

    Comment


    • #3
      Excellent. Thanks Mark.

      Comment

      Working...
      X