Timestamp Locking with Aggregate

Hi,
I’ve run into a little problem whilst upgrading to Toplink 904. I have several classes mapped to tables with timestamp locking enabled. The timestamp field is mapped through an aggregate.
If I enable ‘Store Version in Cache’ at class level, new objects and their timestamps are correctly inserted to database on commit. However, the timestamps are not updated in the respective Toplink objects (they seem to be cached as null). This is problematic, as our app needs this info.
If I disable the ‘Store Version in Cache’ option (which worked for us in Toplink 903), all inserts fail with the message:
2004.07.26 10:47:42.500--UnitOfWork(2086370)--Thread[main,5,main]--java.lang.NullPointerExceptionjava.lang.NullPointerException
     at oracle.toplink.internal.descriptors.ObjectBuilder.mergeChangesIntoObject(ObjectBuilder.java:1458)
     at oracle.toplink.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(MergeManager.java:516)
     at oracle.toplink.internal.sessions.MergeManager.mergeChanges(MergeManager.java:173)
     at oracle.toplink.publicinterface.UnitOfWork.mergeChangesIntoParent(UnitOfWork.java:2501)
     at oracle.toplink.publicinterface.UnitOfWork.commitRootUnitOfWork(UnitOfWork.java:931)
     at oracle.toplink.publicinterface.UnitOfWork.commit(UnitOfWork.java:743)
A solution is to put the timestamp field in a base class, and let the subclasses inherit it. Inserts work and timestamps are correctly updated in the Toplink objects post commit. Before I go change everything around, does anyone know why this doesn’t work when the timestamp fields are mapped through aggregates in Toplink 904?
Thanks,
Steve

Hi,
I’ve run into a little problem whilst upgrading to Toplink 904. I have several classes mapped to tables with timestamp locking enabled. The timestamp field is mapped through an aggregate.
If I enable ‘Store Version in Cache’ at class level, new objects and their timestamps are correctly inserted to database on commit. However, the timestamps are not updated in the respective Toplink objects (they seem to be cached as null). This is problematic, as our app needs this info.
If I disable the ‘Store Version in Cache’ option (which worked for us in Toplink 903), all inserts fail with the message:
2004.07.26 10:47:42.500--UnitOfWork(2086370)--Thread[main,5,main]--java.lang.NullPointerExceptionjava.lang.NullPointerException
     at oracle.toplink.internal.descriptors.ObjectBuilder.mergeChangesIntoObject(ObjectBuilder.java:1458)
     at oracle.toplink.internal.sessions.MergeManager.mergeChangesOfWorkingCopyIntoOriginal(MergeManager.java:516)
     at oracle.toplink.internal.sessions.MergeManager.mergeChanges(MergeManager.java:173)
     at oracle.toplink.publicinterface.UnitOfWork.mergeChangesIntoParent(UnitOfWork.java:2501)
     at oracle.toplink.publicinterface.UnitOfWork.commitRootUnitOfWork(UnitOfWork.java:931)
     at oracle.toplink.publicinterface.UnitOfWork.commit(UnitOfWork.java:743)
A solution is to put the timestamp field in a base class, and let the subclasses inherit it. Inserts work and timestamps are correctly updated in the Toplink objects post commit. Before I go change everything around, does anyone know why this doesn’t work when the timestamp fields are mapped through aggregates in Toplink 904?
Thanks,
Steve

Similar Messages

  • Timestamp locking, last update timestamp

    Let's say there are two tables - Customer and Vehicle; both tables have the "last_update_timestamp" column.
    Assuming the "timestamp locking policy" is used, if the changes to the Customer and Vehicle are in the same transaction, will the updated customer and vehicle records in database have the same timestamp after a successful commit?
    Thanks.

    Haiwei,
    After giving your issue some more thought I wanted post an example of how you could extend TopLink shipped TimestampLockingPolicy to only get the value once per UnitOfwork. The below code is the extension and also includes and easy to use install method to add the policy into your pre-existing system. This should become the default behavior in a future release.
    Cheers,
    Doug
    package model.persistence;
    import java.util.Iterator;
    import oracle.toplink.descriptors.TimestampLockingPolicy;
    import oracle.toplink.internal.descriptors.OptimisticLockingPolicy;
    import oracle.toplink.publicinterface.Descriptor;
    import oracle.toplink.queryframework.ModifyQuery;
    import oracle.toplink.sessions.Session;
    * This extended timestamp locking policy will perform almost identical behavior
    * to its shipped parent. The only difference is that the timestamp value will
    * only be retrieved once for the commit of a UnitOfWork and will be used for
    * all objects in this UnitOfWork with the same locking policy.
    * @author Doug Clarke, TopLink Product Mananger
    * @since TopLink 9.0.4.5 (should work on earlier versions as well)
    public class MyTimestampLockingPolicy extends TimestampLockingPolicy  {
      /** Property key for session (UnitOfWork) properties map. */
      public static final String TS_PROPERTY = "OptLock-new-timestamp";
       * This method will install this extended policy into all descriptors for the
       * given session that use the parent TimestampLockingPolicy. This is typically
       * called from a preLogin session event.
       * <code>
       *   public void preLogin(SessionEvent event) {
       *      MyTimestampLockingPolicy.install(event.getSession());
       * </code>
       * The assumption is that by calling
       * this in the preLogin the session/descriptor/policy are not yet initialized.
       * Some additional code is provided for the case that you are invoking this
       * on a session that is already initialized to ensure the policy is properly
       * configured for use.
       * @param session
      public static void install(Session session) {
        for (Iterator i = session.getDescriptors().values().iterator(); i.hasNext(); ) {
          Descriptor desc = (Descriptor) i.next();
          OptimisticLockingPolicy originalPolicy = desc.getOptimisticLockingPolicy();
          if (originalPolicy != null && originalPolicy.getClass() ==
              TimestampLockingPolicy.class)
            OptimisticLockingPolicy policy = new MyTimestampLockingPolicy(desc, (TimestampLockingPolicy) originalPolicy);
            desc.setOptimisticLockingPolicy(policy); 
            if (desc.isFullyInitialized()) {
              policy.initialize((oracle.toplink.publicinterface.Session) session);
       * This constructor creates a new locking policy to replace the one created by
       * default for timestamp locking. It must copy over the relevant values. It is
       * assumed that the session/desciptor/policy have not yet been initialized.
       * @param descriptor for the policy
       * @param originalPolicy to copy values from
      private MyTimestampLockingPolicy(Descriptor descriptor, TimestampLockingPolicy originalPolicy) {
        super(originalPolicy.getWriteLockFieldName());
        super.setDescriptor(descriptor);
        if (originalPolicy.usesLocalTime()) {
          this.retrieveTimeFrom = LOCAL_TIME;
        } else {
          this.retrieveTimeFrom = SERVER_TIME;
        setIsStoredInCache(originalPolicy.isStoredInCache());
       * Get the next timestamp value. This is where this policy extends the default
       * one. It uses the session (UnitOfWork in this case) properties to cache the
       * timestamp value once it is retrieved the first time from VM or database.
       * The commit cycles of the UnitOfWork, where this is used is single threaded
       * for a given client. For this reason no synchonization is needed on the shared
       * properties.
       * @return New timestamp value to be used in each row's update
      protected Object getNewLockValue(ModifyQuery query) {
        Object tsValue = query.getSession().getProperty(TS_PROPERTY);
        if (tsValue == null) {
          tsValue = super.getNewLockValue(query);
          query.getSession().setProperty(TS_PROPERTY, tsValue);
        return tsValue;   
       * During the insert of a new object an initial timestamp value must be
       * retrieved. This method is written similar to the getNewLockValue.
       * @param session
       * @return New timestamp value to be used in each row's insert
      protected Object getInitialWriteValue(oracle.toplink.publicinterface.Session session) {
        Object tsValue = session.getProperty(TS_PROPERTY);
        if (tsValue == null) {
          tsValue = super.getInitialWriteValue(session);
          session.setProperty(TS_PROPERTY, tsValue);
        return tsValue;   
    }

  • HT201328 Hi there, I purchased an Iphone 4S, it is currently locked with one carrier, I am in a contract with another carrier. I am trying to unlock the phone, but the Carrier says I have to activate it through them to unlock it. I so not want to do that,

    Hi there, my daughter purchased a used iPhone 4S from a local newspaper who has had it in the lost and found for nearly a year, and no one ever claimed it. It is locked with Telus, my daughter is a Virgin Mobile customer. Telus told me they will only unlock it if she activates it with them, she cannot do that as she is in a contract with Virgin. Is there anything I can do to get around this problem?

    Only the carrier to which the iPhone is locked can unlock it. In
    this case, you must work with Telus. If they have a pay as you go
    plan, activate the iPhone on Telus that way and then after
    you meet whatever requirements Telus has, stop using Telus
    and move the iPhone to Virgin. Or sell the iPhone to someone
    who can use it on Telus.
    Telus is the only one who can unlock that iPhone.

  • I am locked out of my iPad, I can't back it up because it won't connect to iTunes (because it's locked with a password) and I need it for school, it has all of my school work on it and the school doesn't have or passwords. PLEASE HELP ME!!!

    I am locked out of my iPad 2, I can't back it up because it won't connect to iTunes (because it's locked with a password) and I need it for school, it has all of my school work on it and the school doesn't have or passwords. I can't loose all of my work. PLEASE HELP ME!!!

    Hi ebby,
    Here are the instructions for a disabled device - hopefully you have sync'd with your computer before now?
    http://support.apple.com/kb/HT1212
    Good luck!
    Cheers,
    GB

  • HT1212 my ipod screen is cracked and i can't sync my ipod on to itunes becauseit it is locked with a password and i can't enter the password because the heat sensor is messed up and i don't want t restore it and lose everything so how can i get passed tha

    My ipod screen is cracked and i can't sync my ipod to itunes because it is locked with a password and i can't enter the password because the heat sensor is messed up on the ipod becasue of the screen and i don't want to restore it and lose everything. What can i do?!

    All you can do is to restore and thus erase the iPod unless you can get a data recovery company to preserve the data.
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                          
    If recovery mode does not work try DFU mode.                         
      How to put iPod touch / iPhone into DFU mode « Karthik's scribblings

  • How do I used my iPhone if it is Lock with an Apple ID account of the previous user and i can't longer contact him?

    I bought an Apple Device namely iPhone 4s and this really bother and give me an intimate reason to contact Apple. How do I use the device, if it is Lock with an Apple ID account of the previous user, and everytime I open the phone the screen will show Activate iPhone with the Apple ID link on the Device. The worse thing is that, i couln't contact the seller any longer and the device is seems useless. I can't use it. Please give me some help how to fix this error and vulnerabilities.

    Sorry alvinguibz, but you have encountered an Activation Lock, and unless you can contact the previous owner and have them follow the steps below, you will not be able to use your device:
    Removing Previous Owner from Device
    There is no other way around this.
    Sorry,
    GB

  • "Photos in the Camera Roll of "(your) iPhone" cannot be imported because the device is locked with a passcode.  You must unlock the device to import them."  My iPhone 5 running the latest iOS 7.1 and I'm using iPhoto '11 v 9.4.3

    "Photos in the Camera Roll of "(your) iPhone" cannot be imported because the device is locked with a passcode.  You must unlock the device to import them."  That's the new error message when I plug in my iPhone 5 running the latest iOS 7.1 into the MacBook Pro running iPhoto '11 v.9.4.3.  My Mac OSX is still 10.8.5.
    So, I unlock the iPhone by entering the "passcode" before I plug it into the MBP and still iPhoto does nothing.  At least it doesn't issue the error message above.
    I've checked both iPhoto preferences and those for Photos and Camera in the Settings on the iPhone.  There doesn't seem to be anything to change this lack of connectivity.
    What next please?

    An hour-long phone discussion with Apple Support yesterday solved this question and sorted a couple of others.
    As for this one, do not ignore any messages which pop up when you plug in your iPhone and ask "Trust this computer?".  The correct reply is "Yes", not "Cancel".
    OK, you cancelled like I did, thinking "What on earth is this for?".  Mistake.  You can force the issue by having iTunes open when you next plug in your iPhone.  Tell the iPhone that it can trust its old friend, your computer and voila!  Your photos can download into iPhoto again.
    Thank you, Jay with Apple Sydney, Australia!

  • My touch shows the connect to itunes with usb on screen however when i try to do so it says it cannot connect because it is locked with a passcode. It will not let me enter the code on the ipod or computer. so i cant do anything. Any ideas?

    I have tried rebooting it. nothing seems to help. it always ends up with the same screen a picture prompting me to hook up via usb to itunes.Then without fail i get an error message. itunes connpt connect to the ipod touch because it is locked with a passcode. you need to enter the passcode on the ipod touch first. unfortunately the touch will not show any other screen but the connect to itunes.

    Connect the iPod touch to your iTunes library in Recovery Mode and restore it to factory setting.  See this article for instructions on getting your device into Recovery Mode.
    http://support.apple.com/kb/ht1808
    B-rock

  • My iPod Touch 5th generation says disabled connect to itunes but when we connect to itunes it says on itunes that the ipod is locked with a passcode and to go onto the ipod and type in the passcode to proceed. What do I do

    My iPod Touch 5th generation says disabled connect to itunes but when we connect to itunes it says on itunes that the ipod is locked with a passcode and to go onto the ipod and type in the passcode to proceed but the ipod is still locked. what do i do?

    http://support.apple.com/kb/HT1212

  • My Ipod Touch is disabled and when I connect to Itunes to recover it, it states that itiTunes could not connect to the iPod touch "iPod touch" because it is locked with a passcode. You must enter your passcode on the iPod touch before it can recover.

    My Ipod Touch is disabled and when I connect to Itunes to recover it, it states that itiTunes could not connect to the iPod touch “iPod touch” because it is locked with a passcode. You must enter your passcode on the iPod touch before it can recover.

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Forgot passcode or device disabled
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:                                                             
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: Back up and restore your iOS device with iCloud or iTunes       
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:           
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        
    If problem what happens or does not happen and when in the instructions? When you successfully get the iPod in recovery mode and connect to computer iTunes should say it found an iPod in recovery mode.

  • I want to unlock my iphone 4s which is locked with orange france , and now i'm in Algeria and we dont have orange here so what can i do???? help please and thank u

    i want to unlock my iphone 4s which is locked with orange france , and now i'm in Algeria and we dont have orange here so what can i do???? and also , my mic doesnt work with siri and dictaphone, it just work with the camera, help me plz and thank u.

    You will have to contact orange to get your phone unlock.  ONly the carrier that the phone is locked to can unlock the phone.

  • Photos in the camera roll of "iPhone cannot be imported because the device is locked with a passcode.  Tried just about everything - suggestions?

    Photos in the camera roll of "iPhone cannot be imported because the device is locked with a passcode.  Tried just about everything - suggestions?

    Because your computer sees your phone, as it would see any digital camera, as long as you have photos in your camera role. Since you state you don't sync with this computer & have a passcode on your phone, that's why you get that message. The only way to prevent that message is either start syncing with this computer; remove the photos from your camera roll prior to connecting; or first turn off your passcode before you connect. Either that, or you live with it.
    You shouldn't be storing photos in your camera roll anyway. iPhone camera roll is not designed for photo storage. You should be regularly importing them.

  • Shattered iPod Touch 4g can't connect to iTunes - locked with passcode?

    Okay, so I have an iPod Touch that was run over by a van and the digitizer is entirely shattered - pieces are falling off and part of the underneath is exposed. The LCD is also non-functional - I only get white (assuming this is just the backlight). I need to backup the content on it but when plugged in, iTunes says it cannot connect because it is locked with a passcode. I know the passcode, but I cannot type it in because the screen does not work. Is there a way for me to type it in from my computer or anything else? All suggestions are appreciated!

    Apple will exchange your iPod for a refurbished one for this price. They do not fix yours. Your data will be lost
    Apple - iPod Repair price      
    A third-party place like the following maybe less. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
    Replace the screen yourself if you are up to it
    iPod Touch Repair – iFixit

  • I have completely disabled my iphone 3gs. It says "Iphone is diabled connect to itunes", but when I connect it to itunes, itunes says "could not connect because it is locked with a passcode you must enter your passcode on the iphone before it can be used.

    My iphone 3gs will no longer let me try passcodes and it only says "Iphone is disabled connect to itunes" well, when I connect it to my laptop, itunes says "could not connect to phone because it is locked with a passcode. you must enter your passcode on the iPhone before it can be used with iTunes" Please help!!! I have tried resetting it and all the tricks I know. Nothing works. Thanks

    You will have to restore it from Recovery Mode: http://support.apple.com/kb/HT1808

  • After itunes installation an error message is shown, (itunes could not connect to the iphone, because it is locked with a passcode, you must enter your passcode on your iphone before it can be used with itunes)

    after itunes installation an error message is shown, (itunes could not connect to the iphone, because it is locked with a passcode, you must enter your passcode on your iphone before it can be used with itunes)

    Hi ..
    Follow the instructions here >  iOS: Forgotten passcode or device disabled after entering wrong passcode

Maybe you are looking for

  • Copy/paste in save as dialog box

    I am using your pdf plugin with Safari but when I click the save icon I cannot paste text into the file name box.  I have to manually type it in.  Can I copy & paste in the save dialog box?

  • IMovie 10.0.6 Text Editing

    Hi, I have now updated to Yosemite and the latest version of iMovie. When I try to edit titles it seems that they have taken out many of the options including drop-shadow etc. Can anyone else confirm this or point me in the right direction? Cheers Be

  • Erro 1306

    New computer, but long time itunes and Ipod mini user. Downloaded itunes with no apparent difficulty. Clicked to run it, but hourglass flashed for a second, then no action. Repeated tries resulted in the same thing. Then, after disabling Norton and o

  • Oracle 10g connectivity with sql server 2000 through oracle transpa gateway

    dear gurus. i am to connecto oracle 10g with sql server 2000 through oracle transparent gateway. i have installed transparent gateway and proper configured. also link is created. but when i execute query "select * from city@inventory" , so an error d

  • Since installing iOS7 I can't switch on wifi in settings. Please help?

    Since installing iOS7 I can't switch on wifi in settings. Please help?