JPA -- How can I turn off the caching for an entity?

Hi,
I have a problem that I will illustrate with a simplified example. I have created an entity:
@Entity(name="Customer")
@Table(name="CUSTOMERS")
public class Customer implements Serializable {
}I have also set the collowing properties in persistence.xml:
<property name="toplink.cache.type.default" value="NONE"/>
<property name="toplink.cache.size.default" value="0"/>
<property name="toplink.cache.type.Customer" value="NONE"/>
<property name="toplink.cache.size.Customer" value="0"/>
<property name="toplink.cache.shared.Customer" value="false"/>And then I run the following code:
Customer cust = em.find(Customer.class, 1L);
System.out.println(cust);
cust = em.find(Customer.class, 1L);
System.out.println(cust);The problem: the second call to em.find does NOT generate a query to the database. Here's a fragment from the console log:
[TopLink Fine]: 2007.05.11 02:55:05.656--ServerSession(2030438)--Connection(5858953)--Thread(Thread[Main Thread,5,main])--SELECT ID, SEX, NAME, MANAGER FROM CUSTOMERS WHERE (ID = ?)
     bind => [1]
Customer: id=1, name=Customer #1, sex=MALE
Customer: id=1, name=Customer #1, sex=MALECan anyone help me? Why isn't the caching turned off? I tried various combinations of properties. Nothing worked. I was expecting to see two queries to the database. I can see only one.
I tried with TopLink Essentials Version 2 Build 39 and Version 2 Build 41.
Best regards,
Bisser

The cache is likely turned off, but you can't tell because you are using the same transactional EntityManager instance for the two queries. The EntityManager requires its own cache for object identity and transactional purposes, as once you read an object in through the EM, the spec requires that all subsequent reads return the same instance. Only the EntityManager refresh will cause a refresh, that or setting your queries to use the toplink.refresh and toplink.cache-usage query hints.
I would strongly recommend you use a query cache for performance, but there are of course reasons why one might not be the best option.
http://weblogs.java.net/blog/guruwons/archive/2006/09/understanding_t.html
is a good blog on understanding the caching used In TopLin Essentials.
Best Regards,
Chris

Similar Messages

  • HT201365 I like the additional security features but don 't want to type in a password every time I use my phone.  How can I turn off the requirement for a password but leave "Find my Phone" active?

    I like the additional security features but don 't want to type in a password every time I use my phone.  How can I turn off the requirement for a password but leave "Find my Phone" active?

    Settings>General>Passcode Lock...enter your passcode, then: Turn Passcode Off.

  • How can you turn off the sounds for receiving a text or e-mail while on a phone call???

    How can you turn off the sounds for receiving a text or e-mail while on a phone call???

    That's the most stupid thing. It may work but the phone shouldn't be going off in your ear while in use from the start.
    Message was edited by: Ford Truck

  • How can I turn off the ringtone for a contact?

    How can I turn off the ringtone for a contact on my iphone 5c?

    krwspike wrote:
    I purchased IPhone silent ringtone
    I've found silent ringtones well worth the investment.

  • How can I turn off the DEP for adobe acrobat standard 8

    Hi all,
    I tried in the settings to add the adobe acrobat standard 8 for exception for DEP, but it doesn't work.
    I am using Windows Vista system, and the error message accured just few weeks ago, in the past I was always able
    to use Adobe Acrobat Standard 8.
    Thank you in advance for your kind support and best regards,
    Stroefli

    Purchase or create a silent ringtone and assign it to that contact.

  • How can I turn off the WLS 6.1 security in order to develop my own application-based security module?

    Dear Colleagues,
    I am currently developing a J2EE application using WLS 6.1.
    My team and I have to implement a security requirement to suit our company's needs.
    The security requirements are that, users' password need to be aged (30 days maximum) and we need to provided a GUI front-end (JSP) to allow users to change their password when these expire after 30 days.
    Our internal contacts in the company, have already taken the lead to find out about whether we will be able to use the WLS 6.1 platform to do this and the answer we got back, was.
    Now we need to develop our own security module.
    I have 2 questions:
    1. How can we turn off the WLS security in order develop our own application-based security module?
    2. How can we develop a security module that allows us to age users' password and provide them with facilities to change their passwords when these expire?
    At the moment, we are using the default BEA WebLogic login.jsp page and there some configuration in the web.xml for this. I will be grateful if you could advise me on how to turn this default security off so that we can write our own security module.

    hi,
    1.You can write your own realm in 61 which can plugged for your security
    calls.
    2. once you write your ownrealm.. you can access it through weblogic
    api/ur api..
    thanks
    kiran
    "Richard Koudry" <[email protected]> wrote in message
    news:3dd0d081$[email protected]..
    Dear Colleagues,
    I am currently developing a J2EE application using WLS 6.1.
    My team and I have to implement a security requirement to suit ourcompany's needs.
    >
    The security requirements are that, users' password need to be aged (30days maximum) and we need to provided a GUI front-end (JSP) to allow users
    to change their password when these expire after 30 days.
    >
    Our internal contacts in the company, have already taken the lead to findout about whether we will be able to use the WLS 6.1 platform to do this and
    the answer we got back, was.
    >
    Now we need to develop our own security module.
    I have 2 questions:
    1. How can we turn off the WLS security in order develop our ownapplication-based security module?
    >
    2. How can we develop a security module that allows us to age users'password and provide them with facilities to change their passwords when
    these expire?
    >
    At the moment, we are using the default BEA WebLogic login.jsp page andthere some configuration in the web.xml for this. I will be grateful if you
    could advise me on how to turn this default security off so that we can
    write our own security module.

  • How can I turn off the yellow pop-up tool tips?

    Howdy,
    I have searched high and low in the preferences and found nothing that does the trick. How can I turn off the yellow pop-up tool tips?
    See attached screen shot. They are incredibly annoying. It's probably obvious, but I cannot find it anywhere on internets or this forum.
    Thanks!

    Thanks Nancy. Unfortunately that doesn't do it. I turned those off awhile back. Nor can I find anything under VIEW that seems to make a difference.  Just FYI: I'm on a Mac OS w/Dreamweaver CS6 - but this has happened on previous versions of DW. Thanks again.

  • How can I turn off the sound from the original midi  or audio tracks when I turned on the duplicate tracks for editing ?

    How can I turn off the sound from the original midi or audio tracks when I edit or listen to the duplicate tracks in Logic Pro 9 ?
    I'm using iMac desktop with Mac OS X Version 10.7.3. Pls advise.

    Dan,
    It sounds like one of your preferences has changed.
    Go to preferences > audio > general, and make sure "track mute/solo" is set to "CPU saving (slow response)". It is probably set to "Fast " at the moment.
    This setting (fast) basically causes immediate muting from the channel strip while your song is in play. This is because the audio is still being read from the hard drive, but the channel strip is simply muted.... like a hardware mixer. When set to "CPU saving", the audio from that track, when muted, is actually stopped from streaming from the hard drive, but there is a couple second delay before the audio is actually muted.
    One would think that the fast setting is generally preferable, except when you need to do what you are doing. The only way to keep duplicate copies of channel strips acting independent of one another is to leave this setting on the "CPU saving" setting.
    Hope that helps

  • I am using earphones, but the external audio of my mini ipad is still on. How can I turn off the external audio while listening with my headset?

    I am using earphones, but the external audio of my mini ipad is still on. How can I turn off the external audio while listening with my headset/earphones?

    Other than iMovie, GB always incorporates the audio files into the GB package. So just save or move the GB project to the external drive, and you're done - anything you import, edit or record will be saved to the external drive.

  • How can I turn-off the apps which I have opened once in ISO 7.0.2. In previous version of ISO it was easy to turn- the opened apps by double clicking on home button and then click and hold on respective apps then click on cross sign.

    How can I turn-off the apps which I have opened once in ISO 7.0.2. In previous version of ISO it was easy to turn-off the opened apps by double clicking on home button and then click and hold on respective apps then click on cross sign but in this version I could not do so and my iPad appears slower.

    Close inactive apps
    1. Double tap the home button to bring up the multi-tasking view
    2. Swipe the app's windows upwards to close
    3. The app will fly off the screen

  • How can you turn off the braille setting on an iPhone 4s, once on it won't let you slide the phone into use mode to change the settings or do anything?

    How can you turn off the braille setting on an iPhone 4s, once on it won't let you slide the phone into use mode to change the settings or do anything?

    An alternate method is Accessibility Settings when connected to iTunes. You should be able to turn it off there. I would also check out some of the answers listed to the right of this post and see if they can help.

  • How can I turn off the wireless modem on my HPG5200uk Desktop?

    How can I turn off the wireless modem on my HPG5200uk Desktop? I have an ethernet connection, and don't want to be blasted by unnecessary radio waves.
    This question was solved.
    View Solution.

    Hi,
    You may not have a wireless network adapter.
    If it is not in Network Adapters and you have no Device Manager errors or disabled devices under Network Adapters then that would be the case.
    Jaco
    Errare humanum est.

  • How can I turn off the 2 blue lines running vertically in my image in Photoshop?

    How can I turn off the 2 blue lines running vertically through my image in Photoshop? I want to save my work but do not know if these lines will persist in the saved image.

    normfb wrote:
    I assume the Rulers are showing. In that case, to get rid of each line use the Move tool to straddle the line and drag it whence it came. I really didn't need to add this comment but it is the first time in years I have had a chance to use the word "whence".
    Is this a guide I see before me? Doeth it conspire to confuseth mine eyes with sapphire lines that afoul my worthy parchment, and draw my quill from its righteous path? Be gone foul guide from whence thou cometh.  Verily, forsooth, and hey nonny nonny.

  • HT1657 How can I turn off the scrolling movie ads in itunes store?

    How can I turn off the scrolling movie ads across the top of the screen when I open the itunes store and am in the movies section?

    Thanks varjak paw.
    I was afraid this was the case.  To the degree that Apple marches down this well-travelled road towards making money by trying to pound customers into submission with flashing ads, etc. that actually serve only to aggravate and drive away at least people like me (28 year user of macs) from both Apple and whatever is being advertised, and indeed get in the way of my being able to efficiently do what is my part of what I always thought was the core of the synergism between Apple and its customers -- them innovating to provide the best tools to help us to be creative and productive, then the company will find itself sharing that space with myriad other companies so bankrupt for ideas and innovation that they have no other possible strategy that to promote mindless consumerism.  That does not seem a place of strength for Apple and a complete forfeiting of its unique position.  Sad to watch.

  • Satellite A660 How can i turn off the lighting of the power button?

    Hello, I recently bought a new Toshiba A660-1FL.
    However bothers me is the lighting of the multimedia keys, if I work in the dark.
    In Bios I could turn off the led illumination, but the power on/off button is still lighting,that distracts me when i am working.
    This notebook has two power LED, so the power on lighting is in my opinion, unnecessary.
    My question is: How can i turn off the lighting of the power button?

    Here you can see the LED with the same function in front of you: http://s3.imgimg.de/uploads/t009aae62jpg.jpg
    Yes in fact, the difference is color, design, but also location and brightness of the LED.
    For me, this LED is too bright and it is distracting in the dark, as you can see here: http://s3.imgimg.de/uploads/leddf570760jpg.jpg
    I was today at a local electronics store, and saw that Toshiba has the brightest Power LED on A660, but why it must be placed under the LCD and not in the front as in my old notebook Toshiba A210.
    I also had the idea with a tape, but it would look ugly, and it must be removable without residue.
    P.S. Also the fingerprints on the glossy keyboard do not look nice.

Maybe you are looking for