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

Similar Messages

  • Manually Refresh Toplink cache

    Gurus,
    Can we write some servlet which will alllow to manually refresh toplink cache, on click of button.
    Do we have to change any settings in session.xml or server.xml.
    Please point me in right direction.
    Thanks
    gbk

    There is no straight forward way of refreshing all the objects in the cache (short of looping through all the objects in the cache and manually refreshing them).
    The most common approach to this issue is to determine which queries need refreshing and refresh those.
    If this solution isn't what you were looking for, please provide more detail and I will be happy to help you further.
    Peter

  • Refreshing TopLink cache problem

    Hello,
    Assume I configure TopLink to cache Class1 and Class2 objects. Class1 is related with Class2 with one-to-one relationship, and Class2 is related with Class1 with one-to-many relationship, Class2 is parent of Class1. When I invalidate instance of Class1 and its parent instance of Class2 with
    session.getIdentityMapAccessor().invalidateObject(object);
    session.getIdentityMapAccessor().invalidateObject(object.getParent());
    and read Class1 by Id with ReadObjectQuery, object of Class1 is refreshed from database, however, if I try to access its parent with Class1#getParent(), that parent is stale, it is not automatically refreshed from database. When I read it (invalidated parent object) with ReadObjectQuery by ID, it is refreshed from database.
    Is there any way to force TopLink to refresh objects that have been invalidated automatically without querying them by ID? If object A of type Class1 has been invalidated, object B of type Class2 has been invalidated, object A references its parent B and I query A by ID, I would like TopLink to refresh not only A, but B object too.

    If the parent is invalidated, then when you access the refreshed Class1's parent the parent should be refreshed. Are you sure you are invalidating both the Class1 and its parent before reading Class1?
    Otherwise I am not sure why you are seeing it not being refreshed.
    Perhaps try this on another object to see if it is something specific to how you have mapped the object.
    Otherwise enable FINEST logging and include the TopLink log.

  • How to refresh JPA cache from non-JPA code(JDBC)

    In the system, let say there are two different tools are available, Tool-A_Uses_JPA and Tool_B_Uses_JDBC.
    As the name of tools is self explanatory what persistence technology used by tools.
    Say,there is a table COMMON_TABLE. This can be used by both tools to perform CRUD operation.
    Lets see the problematic scenario-
    Tool_B_Uses_JDBC tries to insert some new rows in COMMON_TABLE, by performing following tasks--
    (Tool_B_Uses_JDBC already calculated how many rows will be inserted into COMMON_TABLE. Let's say it is 5.)
    1. Read JPA_GENERATED_KEYS table for getting last_value for COMMON_TABLE. Let's say it is 30.
    2. Add (last_value + number of rows to be inserted), here it 30+5 =35.
    3. Update the JPA_GENERATED_KEYS table for last_value of COMMON_TABLE by the value calculated in step 2.
    In my example it was updated by 35.
    Above three steps done in a single transaction.
    Now, ideally if any other tool use this COMMON_TABLE to perform any insert operation, the last_value from
    JPA_GENERATED_KEYS should be 35. But for Tool-A_Uses_JPA, JPA cache is enabled. So this tool still get
    last_value as 30, rather 35. And hence Tool-A_Uses_JPA, does not work properly.
    So to resolve this issue, i thought to write a code to update JPA cache while updating the last_value.
    Is there any way to update and/or send notification to all other tools to update JPA cache when updating
    last_value form NON_JPA code?
    Or is there any other way to resolve this issues?
    Thanks.

    Marking this as answered, as this can never be a situation the way JPA uses caching. This was issue with the transaction form non-JPA code. Actually when JDBC uses data source then whether transaction will be committed as soon as application issues commit, is not guaranteed. Hence need to work on transaction.

  • Toplink Cache not refreshed

    In my project, TOPLINK is used. To carry out the CRUD operation, Stored procedures are used on all objectcs.
    Toplink query is not used.
    In some cases, since we wanted to use the existing Stored procedures for running the business logic, toplink is not used.
    After running these procedures, we refresh the Toplink Cache by using "refreshObject(java.lang.Object p1)" method of UnitOfWork before we read the Object.
    When we read this object, the data appears to be in sinc with what is present in the database tables.
    But when we write the data once again to the database, Toplink some how refers to the Old data ( Data which was present before refreshing).
    It seems to be a strange issue.
    Kindly help.

    If you call refresh on an object already loaded in the UnitOfWork, and the object was modified before you call refresh, the refresh will override the modification done to the object.
    You should never need to call refresh.
    What you should do instead of refresh is to invalidate on session cache so when ever you read the object later, it will be refresh if was invalidated, so more efficient.
    If you use TopLink 11 JPA api you need to flush to get current transaction/uow see the modified data in db.
    But realistically, stored procedure do not work well with O-R framework, and you say Toplink query is not used, why not removing TopLink from the equation? If you want better JDBC you can use iBatis or Spring.

  • OBIEE Cache clear and refresh of reports from DAC

    Hi All,
    I have an existing process where OBIEE cache clear and Dashboard report refresh is happened from DAC.
    But the issue is both do not happen parallely, the both tasks are kept in single text file and they are called from a batch file from DAC. Below is the code
    nqcmd -d AnalyticsWeb -u Administrator -p SADMIN -s D:\OracleBI\server\Bin\PurgeAllCache.txt
    So I want to make them run parellely so that Cache clear and refresh of reports happen parellely. In order to achieve do I need to create seperate batch files or can I manage by changing the above code.
    Please Suggest.

    Can you share the code in the file PurgeAllCache.txt
    There might be some issue with code, make sure you use ';' for each statement.
    or else use 2 files and 2 commands to execute them.
    Pls mark if helps

  • Toplink Cache not getting refreshed after executing UpdateAllQuery

    After executing UpdateAllQuery, the records in the database are getting updated, however the Toplink cache is not getting refreshed with the new data, it still has stale data which is causing issues.
    We're also setting
    updateQuery.setCacheUsage(UpdateAllQuery.INVALIDATE_CACHE);
    Thanks.

    Toplink version is 10.1.3.0.0
    Here is the code
    UpdateAllQuery updateQuery = new UpdateAllQuery(RegisterImpl.class);
    updateQuery.setCacheUsage(UpdateAllQuery.INVALIDATE_CACHE);
    ExpressionBuilder registerBuilder = updateQuery.getExpressionBuilder();
    updateQuery.addArgument("userIdArg");
    updateQuery.addArgument("channelArg");
    updateQuery.addArgument("tokenArg");
    updateQuery.addArgument("dateArg");
    updateQuery.addArgument("businessFuncIdArg");
    Expression reservedDetailRegExp = registerBuilder.get("reservedDetail");
    // build expressions
    Expression userIdExp = reservedDetailRegExp.get("userId").equal(
    registerBuilder.getParameter("userIdArg"));
    Expression channelExp = reservedDetailRegExp.get("channel").equal(
    registerBuilder.getParameter("channelArg"));
    Expression tokenExp = reservedDetailRegExp.get("token").equal(
    registerBuilder.getParameter("tokenArg"));
    Expression dateExp = reservedDetailRegExp.get("date").equal(
    registerBuilder.getParameter("dateArg"));
    Expression busFuncExp = registerBuilder.get("businessFuncId").equal(
    registerBuilder.getParameter("businessFuncIdArg"));
    // set selection criteria
    updateQuery.setSelectionCriteria(userIdExp.and(channelExp.and(tokenExp.and(dateExp
    .and(busFuncExp)))));
    // substitute the values
    updateQuery.addUpdate(reservedDetailRegExp.get("userId"), "");
    updateQuery.addUpdate(reservedDetailRegExp.get("channel"), "");
    updateQuery.addUpdate(reservedDetailRegExp.get("token"), "");
    updateQuery.addUpdate(reservedDetailRegExp.get("date"), "");
    updateQuery.addUpdate(registerBuilder.get("businessFuncId"), "");
    In the object model for the query, the RegisterImpl has an aggregate mapping (ReservedDetail), which in turn has a number of direct-to-field mappings and an one-to-one mapping to businessFunction (for our query we use a direct query key "businessFuncId")

  • Toplink Caching issue

    I have three Entities say C1 , P1 and card. Relation between these
    entities are like this
    P1 to Card ( one - one mapping )
    C1 to Card ( one - many mapping )
    I have three usecases. Usecase 1 uses the mail Entity C1. It will
    create one record using C1. ( keep in mind that there will not be any data for entity card at that time ).
    Second usecase , Usecase 2 , uses Entity P1 and creates data in P1 as
    well as Card.
    Third usecase will again take C1 and try to get the card data which
    were inserted through P1.
    But unfortunately , it is coming as null ... But if I restart the server and access the third usecase then I'm getting all the card data from C1 Entity which were saved through P1 Entity .
    To summarise my finding , issue is with Toplink caching. When i
    accessed the first usecase, C1 is cached. In the second usecase , I updated Entity card using P1. When i accessed the third usecase , toplink is returing the cached entity. Toplink is not able to identify whether related entity got changed or not....
    Workaround is not to use cache for C1 entity. It is working but it will
    not be the correct solution.
    any one faced this issue in Toplink ?
    Correct me if my findings are not correct...

    Hello,
    Its not that the cache isn't working, its that you are updating relationships in the database but not in the cache. Take the case of a 1:M from B->C used in a previous response. It looks like the foreign key used in this relationship (in the C table) is mapped to the C object either as a direct to field mapping, or through a 1:1 to the A object. When you change this so that it now somehow points to the B object, you haven't updated the B object to include the C in its collection. Because B has a 1:M mapping collection of Cs, when you next get that B object from the cache, its collection will not contain the newly referenced C (assuming indirection is not used or has been previously triggered). This is a result of you mapping the 1:M in the first place - since it is storing the collection in the object.
    If you are going to make changes that affect relationships and yet not update the relationships directly I would suggest either:
    A) refreshing affected objects from the database when done. In this case, refreshing the B object will result in TopLink requerying the B->C relation and picking up any changes (depending on your refresh options on the B descriptor though - please check the docs if you need more info).
    B) Not mapping these relationships. Instead, when you need to find C objects referenced from B, query for them.
    Both options are less efficient as they cause more hits to the database. This is why it would be preferred if you updated the relationships when you change fields that affect those relationships, but it is up to you to decide which will work best for your application.
    Please note that the cache is working, in fact the situation you are seeing is due to it working. I am not sure of how your situation would work with DAO as you mentioned in a previous post, but it sounds like it would always hit the database. This situation is a result of you making changes in the database but not changing the object model to reflect those changes, proving that the cache is indeed working. While you mention that some objects are not in your use case, they are in the database but just not mapped in TopLink. In the case of a 1:M mapping, the database shows a 1:1 back relationship that you have not mapped in your object model. So this would be more a case of your object model not matching your database model, and not being taken into account in your use cases.
    Best Regards,
    Chris

  • 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

  • Child Objects  and TopLink Cache

    All,
    I have a problem RE the TopLink cache:
    Object A has a Vector of Object Bs (1:M) and Object B has a Vector of Object Cs(1:M). I am using ValueHolderInterface and indirection pattern for each of these Vectors.
    When I update an Object C, it is not refreshed the next time I read Object A using the readObject(expression). I can see the changes in the database. Can someone tell me the best way to refresh the cache to get the updated Object Cs that belong to Object A.
    What I am doing is updating the C objects that belong to object A (thru Vector B) and then retrieving them again in the very next method call. Hope this makes sense!
    Thanks!
    J

    There is something wrong with your test case, I've seen this before -- if you update a C, then without fail the cached version of C is updated and if you have a handle to the cached A that has the B that has the C in question, then you will see the update. It sounds like perhaps you're not actually looking at the cached A, but instead looking at it from a UOW, etc.
    Send me an email, it's simply my firstname . lastname at Oracle.com. I'll send you a UOW primer that should help better understand these semantics...
    - Don

  • Issues with TopLink Cache Coordination using JMS for manual DB updates

    Hi,
    We are having 2 web application using same Database and Toplink library but 2 session objects for both the applications. We are using JMS for cache coordination. JMS propagating messages successfully between the applications and able to see the same object changes in both the applications properly. Now, we are trying to refresh cache for manual updates in Database. We are trying to refresh single object which is modified in database in one application, refreshing in one application from which refresh happened but not in other application (JMS publishing the topic but updating one).
    Our intention is refreshing in one application so that JMS should coordinate and update in others when DB manual updates. Please let us know any comments for the same.
    Database using: Oracle 11g
    Toplink Version:- 9.0.3

    See,
    http://www.coderanch.com/t/592919/ORM/databases/Toplink-Cache-coordination-JMS-manual

  • Toplink Cache problem

    I am using JDev of following version "Studio Edition Version 10.1.3.1.0.3984
    Build JDEVADF_10.1.3.0_NT_061009.1404.3984".
    I had an application with JSF and Toplink and am facing issues with toplink cache mechanism while TESTING IN JDEV . Following is the scenario.
    1) When clicking on a link, say 'Get status' , i am querying data from database and displaying in JSF.
    2) Later, i am updating particular record.
    3) when i click on the link again (Get status), updated data is not gettng reflected.
    Here is the code to get data and i am calling this method whenever i am clicking on 'Get status' link.
    public Vector getMaintenanceStatusList(){
    Vector lockersStatus = null;
    try {
    Session sess = ToplinkDBUtils.getTopLinkSession();
    sess.validateCache();
    ReadAllQuery query = new ReadAllQuery();
    query.dontCheckCache();
    query.dontMaintainCache();
    query.setReferenceClass(LockerMaintenanceStatus.class);
    query.useDistinct();
    lockersStatus = sess.readAllObjects(LockerMaintenanceStatus.class);
    } catch (DatabaseException e) {
    e.printStackTrace();
    //******** Printing the updated value.
    for (Iterator i = lockersStatus.iterator();i.hasNext();){
    LockerMaintenanceStatus tmp = (LockerMaintenanceStatus)i.next();
    System.out.println("Status value :: "+tmp.getStatus());
    return lockersStatus;
    Here, i am getting old status value for second time though i have updated the database with new status. (scenario if i work in same browser with same toplink session)
    i am getting updated values only when i restart the JDEV oc4j.
    Please let me know how i can solve the problem.
    Thanks!
    Veeraswami K

    Veeraswami,
    In your code you are constructing a query but are not executing it. Instead you are simply calling session.readAllObjects. The result of this call will be the cached versions (based on default cache config).
    I would recommend doing:
    ReadAllQuery query = new ReadAllQuery(LockerMaintenanceStatus.class);
    query.refreshIdentityMapResult();
    lockersStatus = (Vector) sess.executeQuery(query);The other settings you had used would bypass the cache and not result in its results being refreshed.
    Doug

  • Multiple Rows Update / Refresh Toplink Query when database trigger involved

    Hi everybody!
    I have two easy troubles for you; the platform is the same as the SRDemo Toplink version.
    1.     Multiple Rows Update: I want to update with mergeEntity method, multiple rows for an isolated table; that method receives a parameter that I try to bind with the iterator "dataProvider" but it only merges the first row, not all, any other combination returns an error.
    What I want to do is to have a form (like tabular forms in Apex) that lets me update multiple rows in a single page. ¿May anyone tell me how to do it?
    2.     Refresh Toplink Named Query: I have a list on a page with two columns. From another page, a button does an action that fires a database trigger that updates one of the columns on the list´s page. When I go back to the list, it is not updated; however, the CacheResults´s property is set to false on the iterator.
    Thanks in advance,
    Alejandro T

    I didn't use it (yet), but - you might take a look. You'll find a [url http://www.oracle.com/technetwork/developer-tools/apex/application-express/apex-plug-ins-182042.html]Timer plug-in on this page. It is a dynamic action which allows you to periodically fire other dynamic actions in the browser. For example use the timer to refresh a region every five minutes. You can perform any dynamic action you want using this infrastructure.So I was thinking: you might use it to run a dynamic action which would check whether something changed in that table (I suppose you'll know the way) (for example, a database trigger might set a flag in some table, timestamp or similar), and - if you find that something really changed - refresh the page.
    As I said, I never used it so that's pure theory. Someone else might know better, though.

  • After REFRESH the cached object is not consistent with the database table

    After REFRESH, the cached object is not consistent with the database table. Why?
    I created a JDBC connection with the Oracle database (HR schema) using JDeveloper(10.1.3) and then I created an offline database (HR schema)
    in JDeveloper from the existing database tables (HR schema). Then I made some updates to the JOBS database table using SQL*Plus.
    Then I returned to the JDeveloper tool and refreshed the HR connection. But I found no any changes made to the offline database table JOBS in
    JDeveloper.
    How to make the JDeveloper's offline tables to be synchronized with the underling database tables?

    qkc,
    Once you create an offline table, it's just a copy of a table definition as of the point in time you brought it in from the database. Refreshing the connection, as you describe it, just refreshes the database browser, and not any offline objects. If you want to syncrhnonize the offline table, right-click the offline table and choose "Generate or Reconcile Objects" to reconcile the object to the database. I just tried this in 10.1.3.3 (not the latest 10.1.3, I know), and it works properly.
    John

  • How to clear cache from a 11503

    I have a few web servers and a 11503 that is setup to load balance between the web servers. I have turned off my servers for testing and I still see the web content. It doesnt look like my browser, for I can refresh it and the web content still comes up. Im thinking that the 11503 must have cached it and is providing the content. How can I go in and delete that cache from the 11503? Thanks.

    Well read this http://www.cisco.com/en/US/customer/products/hw/contnetw/ps792/products_configuration_guide_chapter09186a008077186c.html#wp1056262
    About the cache ability of CSS it's not that it stores the data locally it can help cache serves to be more efficent and make decisions on weather to send the reques to the cache server or send the request to the server itself with content.

Maybe you are looking for