Keeping the toplink cache insync across a cluster

We would like to deploy our application across a cluster of 10g application servers and we are using toplink as our persistence framework using POJO's. I have been looking around and I have been unable to find anything very helpful on how to setup toplink to be able to keep the cache in sync across the cluster. Has anyone does this on 10g with POJO's? If so can you please point me to an example or a good piece of documentation?
Thanks
Marc

The documentation on Cache synch can be found starting on page 8-3 on the 10g (9.0.4) release.

Similar Messages

  • Querying the toplink cache under high-load

    We've had some interesting experiences with "querying" the TopLink Cache lately.
    It was recently discovered that our "read a single object" method was incorrectly
    setting query.checkCacheThenDB() for all ReadObjectQueries. This was brought to light
    when we upgraded our production servers from 4 cores to 8. We immediatly started
    experiencing very long response times under load.
    We traced this down to the following stack: (TopLink version 10.1.3.1.0)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00002aab08fd26d8> (a oracle.toplink.internal.helper.ConcurrencyManager)
    at java.lang.Object.wait(Object.java:474)
    at oracle.toplink.internal.helper.ConcurrencyManager.acquireReadLock(ConcurrencyManager.java:179)
    - locked <0x00002aab08fd26d8> (a oracle.toplink.internal.helper.ConcurrencyManager)
    at oracle.toplink.internal.helper.ConcurrencyManager.checkReadLock(ConcurrencyManager.java:167)
    at oracle.toplink.internal.identitymaps.CacheKey.checkReadLock(CacheKey.java:122)
    at oracle.toplink.internal.identitymaps.IdentityMapKeyEnumeration.nextElement(IdentityMapKeyEnumeration.java:31)
    at oracle.toplink.internal.identitymaps.IdentityMapManager.getFromIdentityMap(IdentityMapManager.java:530)
    at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.checkCacheForObject(ExpressionQueryMechanism.java:412)
    at oracle.toplink.queryframework.ReadObjectQuery.checkEarlyReturnImpl(ReadObjectQuery.java:223)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.checkEarlyReturn(ObjectLevelReadQuery.java:504)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:564)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:779)
    at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:388)
    We moved the query back to the default, query.checkByPrimaryKey() and this issue went away.
    The bottleneck seemed to stem from the read lock on the CacheKey from IdenityMapKeyEnumeration
    public Object nextElement() {
    if (this.nextKey == null) {
    throw new NoSuchElementException("IdentityMapKeyEnumeration nextElement");
    // CR#... Must check the read lock to avoid
    // returning half built objects.
    this.nextKey.checkReadLock();
    return this.nextKey;
    We had many threads that were having contention while searching the cache for a particular query.
    From the stack we know that the contention was limited to one class. We've since refactored that code
    not to use a query in that code path.
    Question:
    Armed with this better knowledge of how TopLink queries the cache, we do have a few objects that we
    frequently read by something other than the primary key. A natural key, but not the oid.
    We have some other caching mechanisms in place (JBoss TreeCache) to help eliminate queries to the DB
    for these objects. But the TreeCache also tries to acquire a read lock when accessing the cache.
    Presumably a read lock over the network to the cluster.
    Is there anything that can be done about the read lock on CacheKey when querying the cache in a high load
    situation?

    CheckCacheThenDatabase will check the entire cache for a match using a linear search. This can be efficient if the cache is very large. Typically it is more efficient to access the database if your cache is large and the field you are querying in the database is indexed in the table.
    The cache concurrency was greatly improved in TopLink 11g/EclipseLink, so you may wish to try it out.
    Supporting indexes in the TopLink/EclipseLink cache is something desirable (feel free to log the enhancement request on EclipseLink). You can simulate this to some degree using a named query and a query cache.
    -- James : http://www.eclipselink.org

  • How can I keep the browser window stretched across my two displays?

    I run am trying to run dual monitor setup and have the Firefox browser span the two monitors. Whenever a Firefox dialog opens, such as Preferences or Print, the window zooms to fit the one primary monitor. How can I keep the browser window stretched across my two displays?

    Thanks very much for your response to my question -very helpful.
    Do you have any recommendations for a good book on Edge Animate?
    Thanks,
    Shaun
    Date: Thu, 25 Oct 2012 17:10:43 -0600
    From: [email protected]
    To: [email protected]
    Subject: How can I change the browser window background color when playing an Edge animation?
        Re: How can I change the browser window background color when playing an Edge animation?
        created by heathrowe in Edge Animate - View the full discussion
    ADD this to compositionReady handler, change the hex color code to your desired color //Force body of webpage to a specific color$("body").css("background-color","#5d5e61"); Darrell
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/4801409#4801409
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4801409#4801409
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4801409#4801409. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Edge Animate by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Scoping the toplink cache to application

    Hi all, per Active Cache guide, the cache configuration can be scoped at the application level. This is what I am trying to do.
    I have created shared libraries for coherence.jar, active-cahe jar and toplinkgrid jar and am including them in my application's weblogic-application.xml as library reference. The idea is that the cluster will be scoped within my application class loader.
    Now, the next part is also to scope the cache configuration in my application. I have also created a JAR file which contains the cache configuration xml file and have created a shared library and included it as above.
    However, with this, the log out put is as below
    <Sep 16, 2010 11:11:22 AM CST> <Notice> <Stdout> <BEA-000000> <2010-09-16 11:11:22.391/691.970 Oracle Coherence GE 3.5.3/465p2 <Info> (thread=[STANDBY] ExecuteT
    hread: '3' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Loaded cache configuration from "zip:D:/Oracle/Middleware11.1.1.3/coherence_3.5/lib/
    coherence.jar!/reports/report-group.xml">
    I have also tried placing the configuration JAR file in the application EAR file lib directory. I still get the above log statement.
    So, the question is, how do I make coherence pick up my application scoped configuration. I read the Active Cache documentation, but I am not clear about this part.
    Thanks.

    You can use the system propety -Dtangosol.coherence.cacheconfig
    to tell coherence which cache configuration you want to use, for example
    -Dtangosol.coherence.cacheconfig=<location>/hibernate-cache-config.xml

  • How do I keep the IntelliSense cached onto my hard drive, so that whenever I restart Visual Studio, it doesn't need to re-build IntelliSense from scratch?

    Opening a project solution means that I start from where I last left off. If IntelliSense is able to keep its database files, then whenever I call on IntelliSense, it can just go and fetch whatever I typed as any normal operating IntelliSense would do.
    I was just wondering if there is a way to preserve already-built IntelliSense database, so that when I open my Visual Studio project, it doesn't need to generate the IntelliSense database files and I can just call IntelliSense without needing to worry about
    waiting for it to finish generating necessary files.

    No, I do not mean IntelliSense code snippets. What I mean is the PDB database the IntelliSense generates when scanning through codes that the project has. I need to mention beforehand that I have honestly no idea if the PDB file IntelliSense generates is
    related to this.
    This is what I mean:
    What IntelliSense does is it caches all available C++ functions it gathered from the project, and then store them into some database file (which I call it PDB, because it sounds like it's a database file containing all of this auto-completion information),
    so that whenever I call on IntelliSense for auto-completion, it pops up this widget showing all of this for me.
    I wanted to be able to store this generated file permanently, so it doesn't get called over so many times.
    I understand that there is an option to disable auto-updating in the Options > Programming Languages > C++ > Advanced > IntelliSense category. I have that ticked off already, but IntelliSense still generates over and over again each time
    I do a build.
    It makes sense to generate a new PDB for new/removed codes I did in the project, and I can agree, but it
    doesn't make sense to have that same PDB file be generated again and again when all I am doing is just building the same code, without modifying the source code at all, like pressing multiple CTRL+SHIFT+B and closing the program over
    and over again. That behavior is what I would call the PDB file a "cached" file. And I want to keep it when I am building, so that IntelliSense doesn't have to rebuild all the time after I finished a build/compile session and I have to wait a long
    while for me to see what functions I need to use in the project.
    Or maybe there could be a "Search function in IntelliSense context menu...", but I digress.

  • How to keep the form's shape across screens and resolutions?

    Hi All,
    I know that this question is repeated but I didnt found any solutions.
    When I develope a form on a 17 inch monitor and run it from another screen with another dimentions (e.g 15") it looks different the same problem exist when the resolution changed.
    Is there any solution???

    You need to build your forms canvas based on the LOWEST screen resolution you expect the users to use. You especially need to account for users with poor eyesight, who will run with extra low resolutions.
    We code all of our forms to display within the 800 x 600 aspect ratio, because we have some users who need to use that value. Such forms only use a quarter of a full screen on my monitor, but I am not writing forms for only my use.

  • Cluster config. - toplink cache

    hi all!
    A simple question...
    I've built an application using ADF and toplink.
    Actually the application runs on a single IAS.
    now, for load reasons, i'll need to migrate to a cluster configuration.
    Is there any kind of problem with the toplink cache?
    Thanks.
    Luca

    hi all!
    A simple question...
    I've built an application using ADF and toplink.
    Actually the application runs on a single IAS.
    now, for load reasons, i'll need to migrate to a cluster configuration.
    Is there any kind of problem with the toplink cache?
    Thanks.
    Luca

  • Toplink Cache issues in Cluster

    Hi
    Our production environment is have a clustered environment and we have been noticing the following problem. When a user is trying to save a record she repeatedly encounters the "Toplink-5006" exception that I have included below.
    TopLink Error]: 2006.07.19 04:49:23.359--UnitOfWork(115148745)--null--Exception [TOPLINK-5006] (TopLink (WLS CMP) - 10g (9.0.4.2) (Build 040311)): oracle.toplink.exceptions.OptimisticLockException
    Exception Description: The object [[email protected]ce459] cannot be updated because it has changed or been deleted since it was last read.
    Class> com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLink_CMP_2_0 Primary Key> [1001280937, 0]
    [TopLink Error]: 2006.07.19 04:49:23.359--UnitOfWork(115148745)--null--Exception [TOPLINK-5006] (TopLink (WLS CMP) - 10g (9.0.4.2) (Build 040311)): oracle.toplink.exceptions.OptimisticLockException
    Exception Description: The object [[email protected]ce459] cannot be updated because it has changed or been deleted since it was last read.
    Class> com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLink_CMP_2_0 Primary Key> [1001280937, 0]
    <Jul 19, 2006 4:49:23 PM PDT> <Error> <EJB> <BEA-010026> <Exception occurred during commit of transaction Name=[EJB com.rhii.mjplus.fo.people.beans.PeopleManagerBean.setPeople(java.util.HashMap,java.lang.String,java.lang.String,java.lang.String,java.util.HashSet,com.rhii.mjplus.common.login.data.UserInfoDO)],Xid=BEA1-795A6481D2E1938A8EAD(115171166),Status=Rolled back. [Reason=Exception [TOPLINK-5006] (TopLink (WLS CMP) - 10g (9.0.4.2) (Build 040311)): oracle.toplink.exceptions.OptimisticLockException
    Exception Description: The object [[email protected]ce459] cannot be updated because it has changed or been deleted since it was last read.
    Class> com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLink_CMP_2_0 Primary Key> [1001280937, 0]],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=60,XAServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(ServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(state=rolledback,assigned=MS15_mjp),xar=weblogic.jdbc.wrapper.JTSXAResourceImpl@6dcf50b),SCInfo[mjp+MS15_mjp]=(state=rolledback),properties=({weblogic.transaction.name=[EJB com.rhii.mjplus.fo.people.beans.PeopleManagerBean.setPeople(java.util.HashMap,java.lang.String,java.lang.String,java.lang.String,java.util.HashSet,com.rhii.mjplus.common.login.data.UserInfoDO)], weblogic.jdbc=t3://10.253.129.56:2323}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=MS15_mjp+10.253.129.56:2323+mjp+t3+, XAResources={},NonXAResources={})],CoordinatorURL=MS15_mjp+10.253.129.56:2323+mjp+t3+): Local Exception Stack:
    Exception [TOPLINK-5006] (TopLink (WLS CMP) - 10g (9.0.4.2) (Build 040311)): oracle.toplink.exceptions.OptimisticLockException
    Exception Description: The object [[email protected]ce459] cannot be updated because it has changed or been deleted since it was last read.
    Class> com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLink_CMP_2_0 Primary Key> [1001280937, 0]
         at oracle.toplink.exceptions.OptimisticLockException.objectChangedSinceLastReadWhenUpdating(Ljava/lang/Object;Loracle/toplink/queryframework/ObjectLevelModifyQuery;)Loracle/toplink/exceptions/OptimisticLockException;(OptimisticLockException.java:109)
    What is puzzling is that the occurance of this nature has increased with user load and the toplink cache does not seem to have been refreshed after it encounters the first Optimistic Lock exception. We have run several test and this is not reproducabile in the DEV environment where we do not have a clustered set. After making a few updates to a record users starts experiencing the problem ... for some this persist for a really long time.
    We do not have Cache synchronization
    Cluster setup is as followes
    There are 4 boxes and each box has one admin and 4 managed servers.
    I have included the toplink-cmp-people.xml ( Thisis the particular entity bean we have a problem with) Our application server is Weblogic and we have Toplink version 9042
    <toplink-ejb-jar>
    <session>
    <name>People</name>
    <project-class>
    com.rhii.mjplus.fo.people.beans.PeopleToplink
    </project-class>
    <login>
    <datasource>MJPool</datasource>
    <non-jts-datasource>MJPool</non-jts-datasource>
    </login>
    <use-remote-relationships>true</use-remote-relationships>
    <customization-class>com.rhii.mjplus.common.TopLinkCustomization
    </customization-class>
    </session>
    </toplink-ejb-jar>
    I would appreciate any kind of feedback
    Thanks
    Lakshmi

    Can you refresh that record using a query before you save it ?
    Hi
    Our production environment is have a clustered
    environment and we have been noticing the following
    problem. When a user is trying to save a record she
    repeatedly encounters the "Toplink-5006" exception
    that I have included below.
    TopLink Error]: 2006.07.19
    04:49:23.359--UnitOfWork(115148745)--null--Exception
    [TOPLINK-5006] (TopLink (WLS CMP) - 10g (9.0.4.2)
    (Build 040311)):
    oracle.toplink.exceptions.OptimisticLockException
    Exception Description: The object
    [com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLin
    k_CMP_2_0@6dce459] cannot be updated because it has
    changed or been deleted since it was last read.
    Class>
    com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLink
    CMP2_0 Primary Key> [1001280937, 0]
    [TopLink Error]: 2006.07.19
    04:49:23.359--UnitOfWork(115148745)--null--Exception
    [TOPLINK-5006] (TopLink (WLS CMP) - 10g (9.0.4.2)
    (Build 040311)):
    oracle.toplink.exceptions.OptimisticLockException
    Exception Description: The object
    [com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLin
    k_CMP_2_0@6dce459] cannot be updated because it has
    changed or been deleted since it was last read.
    Class>
    com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLink
    CMP2_0 Primary Key> [1001280937, 0]
    <Jul 19, 2006 4:49:23 PM PDT> <Error> <EJB>
    <BEA-010026> <Exception occurred during commit of
    transaction Name=[EJB
    com.rhii.mjplus.fo.people.beans.PeopleManagerBean.setP
    eople(java.util.HashMap,java.lang.String,java.lang.Str
    ing,java.lang.String,java.util.HashSet,com.rhii.mjplus
    .common.login.data.UserInfoDO)],Xid=BEA1-795A6481D2E19
    38A8EAD(115171166),Status=Rolled back.
    [Reason=Exception [TOPLINK-5006] (TopLink (WLS CMP) -
    10g (9.0.4.2) (Build 040311)):
    oracle.toplink.exceptions.OptimisticLockException
    Exception Description: The object
    [com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLin
    k_CMP_2_0@6dce459] cannot be updated because it has
    changed or been deleted since it was last read.
    Class>
    com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLink
    CMP2_0 Primary Key> [1001280937,
    0]],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds
    since begin=0,seconds
    left=60,XAServerResourceInfo[weblogic.jdbc.wrapper.JTS
    XAResourceImpl]=(ServerResourceInfo[weblogic.jdbc.wrap
    per.JTSXAResourceImpl]=(state=rolledback,assigned=MS15
    _mjp),xar=weblogic.jdbc.wrapper.JTSXAResourceImpl@6dcf
    50b),SCInfo[mjp+MS15_mjp]=(state=rolledback),propertie
    s=({weblogic.transaction.name=[EJB
    com.rhii.mjplus.fo.people.beans.PeopleManagerBean.setP
    eople(java.util.HashMap,java.lang.String,java.lang.Str
    ing,java.lang.String,java.util.HashSet,com.rhii.mjplus
    .common.login.data.UserInfoDO)],
    weblogic.jdbc=t3://10.253.129.56:2323}),OwnerTransacti
    onManager=ServerTM[ServerCoordinatorDescriptor=(Coordi
    natorURL=MS15_mjp+10.253.129.56:2323+mjp+t3+,
    XAResources={},NonXAResources={})],CoordinatorURL=MS15
    _mjp+10.253.129.56:2323+mjp+t3+): Local Exception
    Stack:
    Exception [TOPLINK-5006] (TopLink (WLS CMP) - 10g
    (9.0.4.2) (Build 040311)):
    oracle.toplink.exceptions.OptimisticLockException
    Exception Description: The object
    [com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLin
    k_CMP_2_0@6dce459] cannot be updated because it has
    changed or been deleted since it was last read.
    Class>
    com.rhii.mjplus.fo.people.beans.People_z2e2a7__TopLink
    CMP2_0 Primary Key> [1001280937, 0]
    at
    t
    oracle.toplink.exceptions.OptimisticLockException.obje
    ctChangedSinceLastReadWhenUpdating(Ljava/lang/Object;L
    oracle/toplink/queryframework/ObjectLevelModifyQuery;)
    Loracle/toplink/exceptions/OptimisticLockException;(Op
    timisticLockException.java:109)
    What is puzzling is that the occurance of this nature
    has increased with user load and the toplink cache
    does not seem to have been refreshed after it
    encounters the first Optimistic Lock exception. We
    have run several test and this is not reproducabile
    in the DEV environment where we do not have a
    clustered set. After making a few updates to a record
    users starts experiencing the problem ... for some
    this persist for a really long time.
    We do not have Cache synchronization
    Cluster setup is as followes
    There are 4 boxes and each box has one admin and 4
    managed servers.
    I have included the toplink-cmp-people.xml ( Thisis
    the particular entity bean we have a problem with)
    Our application server is Weblogic and we have
    Toplink version 9042
    <toplink-ejb-jar>
    <session>
    <name>People</name>
    <project-class>
    com.rhii.mjplus.fo.people.beans.PeopleToplink
    </project-class>
    <login>
    <datasource>MJPool</datasource>
    <non-jts-datasource>MJPool</non-jts-datasource>
    </login>
    <use-remote-relationships>true</use-remote-relationsh
    ips>
    <customization-class>com.rhii.mjplus.common.TopLinkCu
    stomization
    </customization-class>
    </session>
    </toplink-ejb-jar>
    I would appreciate any kind of feedback
    Thanks
    LakshmiCan you refresh that record using a query before you save it ?

  • Keeping the values in Request bean across more than 2 pages

    Hi...,
    I have created a Bean with request scope & want to access it across 3 different pages.
    From the 1st page once I submit the values , I do a forward (redirect=no) to the second page where I can print the values . From the 2nd page I then do a forward to the 3rd page (redirect=no) & I loose the values.
    How do I keep the request bean active across multiple pages. But I don't want to make it session as this is a form to enter values & our users might open multiple forms as the same time.
    Regards,
    Praveen

    Hi....Balu,
    We are having a issue when using ajax on top of JSF . Setting the variable hidden is somehow not working.
    Secondly, what is requestMap & where can I find the information.
    Regards,
    Praveen

  • Toplink cache performance

    I have the following problem:
    A j2ee struts application deployed over a cluster of 4 application server (10g). Machines Sun Solaris, configured identically with one OC4J container and three processes(3 jvm's). Memory always keeps growing till the max configured in the java options. Which is set to 1,5 Gb (we have tried with a lower Xmx1GB and even Xmx2GB)...
    Once that number is hit than the CPU turns high, and the controller ping process of the application server forcefully terminates the process(es) which can not be reached by the ping process.
    Load: approximately 1500 users per day, with high degree of updates and inserts.
    My question: can the toplink cache,(most of the classes are configured SoftCacheWeakReference) be the cause of this ridiculous memory growth?

    Seems like your application has a memory leak somewhere. You may wish to analyze your app servers memory usage with memory profiling tools, such as JProbe memory profiler.
    Unless you have a very large cache size, I would not expect the SoftCacheWeakIdentityMap to cause a memory issue. You can verify this by changing your caching type to WeakIdentityMap. Also double check that you are not using a FullIdentityMap anywhere, nor using a very large cache size.
    Also verify your application does not holding references to objects and not allowing them to garbage collect.

  • Toplink cache

    Hi,
    I am having severe memory problems using Toplink Essentials. What I am experiencing is a growing memory consumption every time an entity is persistent, no matter I set in persistence.xml
    <property name="toplink.cache.type.default" value="Weak"/>
    and
    <property name="toplink.cache.size.default" value="10"/>
    I used the Java Visual VM supplied with the sun 1.6.0.07 sdk to analize the heap.
    The behaviour I am expecting is:
    when a persistent class is not referenced by my application anymore, it should be kept in the toplink cache with a weak reference, to be garbage collected as soon as the JVM is running out of memory.
    What I see instead :
    for each class I persist I find roughly 3 instances in memory and they seems to be strongly referenced. In addition, after a while the program start slowing down (each persist takes longer, I guess this is the cost for the cache lookup, but in my real application it ends up using more than a second for each persist!)
    Workaround: I found EntityManage.clear() wipes out the cache freeying the memory, but I am not sure this is free from side effects (all the entities are detached I guess)
    I attacked a test case: just the simplest entity possible, filled with a random integer and persisted. Leave it running for maybe 10 minutes.
    After a while have:
    2000 entities persisted
    6000 instances in the heap
    12000 oracle.toplink.essentials.internal.helperIdentityHashtable$Entry
    Persisting is now taking ~50ms instead of 5ms (and growing)
    Am I doing something wrong?
    This is my entity:
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    @Entity
    public class AnEntity {
         @Id
         @GeneratedValue(strategy = GenerationType.IDENTITY)
         @Column
         protected int     anEntityID;
         protected int     data;
         protected AnEntity() {
         public AnEntity(final int data) {
              this.data = data;
    My main application:
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.EntityTransaction;
    import javax.persistence.Persistence;
    public class Test {
         public static void main(final String[] args) throws InterruptedException {
              new Test();
         final EntityManagerFactory     emFTest     = Persistence.createEntityManagerFactory("test_pu");
         private final EntityManager     emTest     = emFTest.createEntityManager();
         public Test() throws InterruptedException {
              int i = 0;
              while (true) {
                   final AnEntity entity = new AnEntity((int) (Math.random() * 1000000));
                   final long time = System.nanoTime();
                   try {
                        final EntityTransaction trans = emTest.getTransaction();
                        trans.begin();
                        emTest.persist(entity);
                        trans.commit();
                   } catch (final Exception e) {
                        System.err.println(e.getMessage());
                   System.out.println("It took:" + (System.nanoTime() - time) / 1000000 + "ms for " + i);
                   i++;
                   Thread.sleep(100);
    And my persistence.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
              <persistence-unit name="test_pu" transaction-type="RESOURCE_LOCAL">
                        <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
                        <class>AnEntity</class>
                        <properties>
                             <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver" />
                             <property name="toplink.jdbc.url" value="jdbc:mysql://test:3306/test" />
                             <property name="toplink.jdbc.user" value="test" />
                             <property name="toplink.jdbc.password" value="test" />
                             <property name="toplink.logging.level" value="INFO" />
                             <property name="toplink.ddl-generation" value="create-tables" />
                             <property name="toplink.cache.type.default" value="Weak"/>
                        </properties>
              </persistence-unit>
    </persistence>

    Hi Chris,
    I see your point, and this is what I am trying to obtain, I am sure i am getting the underlying JPA phylosophy wrong (as a side note, I already moved to Eclipselink :) )
    What I have is a fleet of vehicles, each one sending the gps position once per second. All the position are stored in the database.
    The communication between each veichle and the "server application" is through JMS, so I effectively receive a bunch of positions every second - no easy way to put them in the same transaction, but it is not a big hit on the database so I am not concerned about this.
    What I noticed is after something like 30 minutes the application starts struggling, every persist took 300ms, positions started accumulating as he software did not manage to write them as fast as they are generated and everything start collapsing badly - it took 15 days to find out the problem was with the toplink cache.
    I am trying to work out the best way of doing things.
    What I noticed is, if I recreate the EM, all the entities are detached (and I understand why - entities are managed by the entity manager!).
    I understand there are two caches, the session cache and the UoW cache (EM).
    What I desire at a conceptual level is to keep my entities managed until I do not reference them anymore. If I need them again, I have to retrieve them back with em.find, or I can create new ones.
    Unfortunately things seems not to be working this way - EM keep everything in cache even if do not have any reference to an instance.
    I have quite a good level of control over the global cache, but no control at all over the EM cache (apart from completely wiping it) so I have to recreate the EM every time, but the object are not managed this way - forcing me to use merge in place of persist (I basically would like the best of the two worlds).
    This is not a problem by itself, but this forces me to write code like
    entity=em.merge(entity)
    or better:
    AnEntity tmp=em.merge(entity)
    entity.anEntityID=tmp.anEntityID
    to handle the case this is a new entity. This is my new code, everytime I have to update the db
    final EntityManager emTest = emFTest.createEntityManager();
    final EntityTransaction trans = emTest.getTransaction();
    trans.begin();
    final AnEntity tmp = emTest.merge(entity);
    trans.commit();
    entity.anEntityID = tmp.anEntityID;
    emTest.close()
    while with a global EM it was:
    final EntityTransaction trans = emTest.getTransaction();
    trans.begin();
    emTest.persist(entity);
    trans.commit();

  • How to Add Index in Toplink Cache

    Hi
    We are using toplink as ORM.we are using default cache option (soft cache weak identity)provided by toplink, need to optimize the object retrival from cache, is there any option to create Index ( like database index) on the toplink cache.
    Message was edited by:
    [email protected]

    The TopLink cache is indexed by primary key only. It does not support additional indexes.
    Doug

  • Refresh toplink cache from tirgger

    How to update the toplink cache due to change in the database by some external process or procedure?
    This question was posted some time back and one of the suggestion was to create a trigger on the table holding the data and implement callout to the toplink cache to refresh. I will appreciate if any one can let me know where I can I find more information to implement such a callout method from trigger on the database table.
    We are accessing the toplink objects from OC4J container from where a singleton is managing the calls to the toplink objects. We already have methods in place to refresh the cached object based on timeouts but now the new requirements are to refresh the objects only if the data is changed in the database.
    Thanks
    Ahmad

    I have url error on this thread : How to refresh cache in TopLink, turn off cache
    [b]Discussion Forums Error
    We cannot process your request at this time. Please try again later.
    Thank's

  • How do I sync Toplink Cache with my Database?

    Hey guys,
    We are running macro's through an excel sheet that connects to the database and performs Updates and Inserts.
    Since this database update is NOT taking place through TopLink (in a Unit of Work) - we do not see the database changes through the web app on the front end unless we bounce our webserver. Presumably the Toplink cache is re-built on start up...so then we can see the changes.
    My question is, what can I do to make sure the TopLink cache is aware of the database changes we have made through the macro without having to bounce the server? Is there a re-fresh or sync command that can be run?
    This task is sort of a one time thing, so I don't want a solution that involves the cache going to sync itself on a schedule or anything like that. Maybe bouncing is the best solution?
    Thoughts?
    We are using Toplink 9.0.4
    Thanks.

    Hello,
    Because it is a one time thing, if you can make sure no other TopLink process are going on, you can probably get away with initializeAllIdentityMaps() or the intitializeIdentityMap(Class) methods on the session. These will clear the identity maps, having the obvious draw back of removing all object identity which will cause problems with running processes though. It might be better than bouncing the server - it depends on the application. Logging out of the session and logging back in has the same effect of clearing the cache, but with a bit more overhead. Benifit is that running processes will get errors if they continue to use the session, rather than strange behaviior if they continue to use objects after identity is lost.
    Another alternative is to run refresh queries on the data you know might be in the cache or that might have been affected. Drawbacks are that this brings them into the cache if they are not already there.
    TopLink 9.0.4 is a quire a few versions back, and in newer versions there is cache invalidation. An object marked as invalid is not removed, so object identity is maintained, but on the next query the data will be refreshed - ensuring subsequent queries will get results from the database without having to be told explicietly to refresh or being set to always refresh. Invalidation can be triggered on particular objects, classes or the entire cache or different policies can be set to set a time to live etc.
    Except for bouncing the server or logging out of the session, all of the above leave some possibility that a concurrent user will still have a reference to stale data and continue to use it after the process has run on the database. So I hope you use optimistic locking and that your batch process updates the version to avoid other process from overwriting with stale data.
    Best Regards,
    Chris

  • Querying by PK against Toplink Cache

    Lets say I have table A that has PK id.
    If toplink generates SQL like this:
    "select id from A where 1=1 and id=3"
    Assuming the data is already cached against that PK, will Toplink retrieve the data from the Toplink cache with this SQL? or since i used 1=1, will it not find it in the cache and require a database retrieval?
    Thanks,
    Zev.

    Doug, thanks for the response. I expected it since we have seen a large increase in SQL. Let me explain the reason for this and maybe you can point us in a better direction.
    We generate a Map of CriteriaValue Objects. The in our base object, we iterate over the map and based on the criteria, we build the appropriate expression.
    Here is the code for the iteration.
              CriterionValue criterionValueObj;
              selectionExpression = builder.prefixSQL("1=1");
              while (keyIterator.hasNext()) {
                   String key = (String) keyIterator.next();
                   criterionValueObj = (CriterionValue) criteriaHash.get(key);
                   selectionExpression = getExpression(builder, selectionExpression, criterionValueObj, key, firstTimeThroughLoop);
                   firstTimeThroughLoop = false;
    As you can see, we add a prefix of 1=1. The reason for this is that if this is the first time through the look, we need to say:
    ExpressionBuilder builder; //just showing the declaration type
    selection = builder.get(key).containsSubstring(value.toString());
    if it is the second time through (with conjunction)
    ExpressionBuilder builder; //just showing the declaration type
    selection = selection.and (builder.get(key).containsSubstring(value.toString()));
    so we need two seperate code blocks in this case. A tremendous code minimization in our base class is to say 1=1 AND then it is as if we are always accessing it the second time.
    Do you have any suggestions for us? I do not want modify the caching options programitically.
    Thanks,
    Zev.

Maybe you are looking for

  • I bought the wrong app

    I am new in iPad and I was looking for power point app and I bought a tutorial power point.

  • Metadata from Onlocation not showing up in Bridge

    This might be a question better suited to the Bridge forum, but I've posted there with no reply.   I want my onLocation 'comment' and 'description' metadata to be viewable in Bridge, in one of the file columns.    I realize it is visible in the 'meta

  • Backing Up w/ Time Machine (Leopard to Snow Leopard)

    Hi Srry if this question has been answered somewhere but I couldn't locate any posts. I wish to jump over to snow leopard from leopard on my 08 blackbook. Will all my programs etc be backed up? How do I perform the restore? Thanks for any help!

  • Pricing structure for vendors

    Dear friends, I want to define a pricing procedure for the following scenario pls help: For local vendors Total price = basic price + discount + freight cost For foreign vendors Total price = basic price + discount + freight cost + Customs Tks Kali

  • ITunes Functionality Suggestions

    Can Apple add the following suggestions to the 'wish list' for iTunes: 1) Stop ctl & click on tick box selecting/deselecting all tracks - this short cut is easily used by accident when selecting tracks for editing and effectively erases all previousl