Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » second level cache without persistence.xml
second level cache without persistence.xml [message #1124572] Thu, 03 October 2013 13:25 Go to next message
Omid Pourhadi is currently offline Omid Pourhadi
Messages: 11
Registered: May 2013
Junior Member
I'm using eclipse link and spring as follow

<bean id="emf"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
                <property name="generateDdl" value="false"/>
                <property name="showSql" value="true" />
                <property name="database" value="POSTGRESQL"/>
                <property name="databasePlatform" value="org.eclipse.persistence.platform.database.PostgreSQLPlatform"/>
            </bean>
        </property>
        <property name="jpaDialect">
            <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect"/>
        </property>
        <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
        </property>
        <property name="packagesToScan" value="org.omid.model"/>
        <property name="jpaProperties">
            <props>               
                <prop key="eclipselink.cache.shared.default">false</prop>
                <prop key="eclipselink.query-results-cache">true</prop>
                <prop key="eclipselink.logging.session">true</prop>
            </props>
        </property>
    </bean>


as you can see because of packagesToScan I don't have persistence.xml.
my first question is how I can enable selective cache ?

I've tried this

@Entity
@Cacheable(true)
@Cache(
  type=CacheType.SOFT, // Cache everything until the JVM decides memory is low.
  size=64000,  // Use 64,000 as the initial cache size.
  expiry=36000000
)
public class Employee {
  ...
}

but it doesn't working.
am I missing something ?
Re: second level cache without persistence.xml [message #1125551 is a reply to message #1124572] Fri, 04 October 2013 12:39 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 928
Registered: July 2009
Senior Member
How are you testing that it isn't working? Each EntityManager has its own first level cache, could that be what you are seeing?

Best Regards,
Chris
Re: second level cache without persistence.xml [message #1126065 is a reply to message #1125551] Sat, 05 October 2013 01:32 Go to previous message
Omid Pourhadi is currently offline Omid Pourhadi
Messages: 11
Registered: May 2013
Junior Member
when I enable shared
<prop key="eclipselink.cache.shared.default">true</prop>
only first time query is executed but in the above case every time I try to load data query will be executed.
Previous Topic:BUG : postgresql @NamedStoredProcedureQuery call
Next Topic:How to create POJOs with JAXB and JPA Annotations from XSD?
Goto Forum:
  


Current Time: Mon Oct 07 16:32:07 EDT 2013

Powered by FUDForum. Page generated in 0.01591 seconds