External transaction control and ability to find new registered objects

Hello, We are using Toplink with external transaction control and have a process inserting a complex hierarchy of objects. During the process we either do a registerObject or deepmergeClone depending on if the instance is already in the db. With external transaction control the registerObject does not actually do the commit to db until the global transaction (Container) issues the commit. Unfortunately we end up doing creating multiple instances of same objects ( because the assumption that registerObject would have written the row to the db ) with the same keys and when the container issues the commit we end up with duplicate key violation. Is there a way to find out if an object with a particular key is already registered?

This sounds like the kind of question that can only be answered with a whiteboard and a good review of your architecture.
In general, there should be no problem registering objects multiple times. I.e.,
x = some object
x1 = uow.registerObject(x);
Then x1==uow.registerObject(x), and x1==uow.registerObject(x1), etc. When you register an object with the UOW, based on PK it'll always return that same one.
Do you have multiple units of work on the go? (that may explain this behavior).
In any case, I think the real problem here is that you're somehow registering objects that are no longer cached. I.e., some object is serialized or rebuilt and then registered after it's gone from the cache. By default, TopLink determines if an object is new or existing (to determine INSERT vs UPDATE) by hitting the cache. You can change this default behavior in the Mapping Workbench, open the advanced property for "Identity" and change existence checking to "check database". Although, this can be a slow and tedious process to have to keep hitting the DB.
A little trick I use sometimes is to take advantage of the "readObject" API that will read the object from the databaes if it's not already in cache, and just return it from cache if it is in cache. Check out the UOW primer at http://otn.oracle.com/products/ias/toplink/index.html for more info, but the jist is that I would do this if I were you:
x = some object that you're not sure is cached and you want to register in UOW;
x' = uow.readObject(x);
IF the object was in cache, you'd get back a working copy, nice and fast. IF it's not in cache, you hit the database, it goes in cache, and you get your working copy. Now you don't have to change the existence checking option which could slow everything down.
- Don

Similar Messages

  • UnitOfWork event and External Transaction Control

    Hi
    I'm running Toplink 9.0.3 with JBoss 3.2.2. Toplink is configured with an external transaction controler. My code is running inside a Session Bean, with CMT (Container Managed Transaction). My bean's transaction type is "Required" so the JTS transaction is already started when I call getActiveUnitOfWork().
    What I want to do is register a listener on the UOW's preCommit event. When I do, the listener is never called... Is it an issue with Toplink or is it me who is missing something?
    Thanks a lot
    Regards
    Eric

    Hi Eric,
    When configured correctly the registration of the listener should happen when you acquire the unit of work, and if logging is appropriately enabled you should see the #register log message on the console. You should not need to do anything in preCommit. Make sure that you have:
    - set the login to useExternalTransactionController()
    - set the controller instance on the session
    e.g. session.setExternalTransactionController(new JTSExternalTransactionController()
    - set the TransactionManager on the JTS listener class.
    e.g.
    TransactionManager jbossTM = ... // look up TM
    JTSSynchronizationListener.setTransactionManager(jbossTM)
    You will have to look up the JBoss TransactionManager in JNDI in order to set it on the listener class. I can't remember what name it is posted under in 3.22 but it is something generic (javax.transaction.TransactionManager, or something like that -- your app server doc should tell you).
    If you are using sessions.xml then the equivalent elements exist there as well to set the first two parts.
    -Mike

  • HT1473 Help I just moved my music files to a external hard drive and am using the new crappy version ( i know my opinion) of itunes and cant add the files to my libray it gives me the add file to library option but not the add folder to library option wha

    Help I just moved my music files to a external hard drive and am using the new crappy version ( i know my opinion) of itunes and cant add the files to my libray it gives me the add file to library option but not the add folder to library option what am i doing wrong?

    In iTunes 11 uncheck the preferences setting in in the iTunes Preferences panel "Advanced > Copy Files to iTunes Media folder when adding to Library"

  • Renamed my external hard drive and now cant find photos

    After renaming an external hard drive, what do i do to 'update my folders in lightroom' where to go to find my pics i edited and save to that drive. i originally had it named 'My Book' and renamed it "external 2". i even renamed it back to 'My Book' and lightroom still doesn't show them in the folder area.
    thanks for the help

    thanks for all the great info!!!!!
    Show me your passion and I'll immortalize it.
    Scott [email protected]om
    Date: Thu, 4 Feb 2010 16:04:43 -0700
    From: [email protected]
    To: [email protected]
    Subject: Renamed my external hard drive and now cant find photos

  • Upgraded and can't find new CD.

    Upgraded to latest Itunes...
    Bought new CD Benq 1640 below...2 weeks ago.
    go to burn CD "No burner or software found"
    in itunes under burning tab it shows Lite-on model.
    Lite-on model no longer in computer.
    Reinstalled, repaired, edited the cfg file.
    Evens show lite-on after a uninstall---yes from add and remove programs section...
    Can import from either drive listed below.
    Can not burn appears to look for Lite-on.
    Help!!
    Additional info:
    cd diag...
    Microsoft Windows XP Professional Service Pack 2 (Build 2600)
    iTunes 5.0.1.4
    CD Driver 2.0.4.3
    CD Driver DLL 2.0.3.2
    UpperFilters: GEARAspiWDM (2.0.4.3),
    Video Driver: NVIDIA GeForce4 Ti 4200 with AGP8X \GeForce4 Ti 4200 with AGP8X
    IDE\DiskMaxtor6L120P0_________________________BAH41G10, Bus Type ATA, Bus Address [1,0]
    IDE\DiskWDCWD1600JB-00GVA0____________________08.02D08, Bus Type ATA, Bus Address [0,0]
    USBSTOR\DiskEPSON__Stylus_Storage_1.00, Bus Type USB
    IDE\CdRomBENQDVD_DD_DW1640______________________BSLB___, Bus Type ATAPI, Bus Address [0,0]
    IDE\CdRomJLMSDVD-ROM_LTD-166S___________________DS0E___, Bus Type ATAPI, Bus Address [1,0]
    Current user is administrator.
    D: BENQ DVD DD DW1640, Rev BSLB
    Audio CD in drive.
    Found 10 songs on CD, playing time 52:10 on Audio CD.
    Track 1, start time 00:02:00
    Track 2, start time 04:38:36
    Track 3, start time 10:24:03
    Track 4, start time 13:59:23
    Track 5, start time 17:46:57
    Track 6, start time 24:18:51
    Track 7, start time 31:53:17
    Track 8, start time 36:25:45
    Track 9, start time 41:58:34
    Track 10, start time 48:07:27
    Audio CD reading succeeded.
    Get drive speed succeeded.
    The drive CDR speeds are: 12 16 24 32 40 48.
    The drive CDRW speeds are: 12.
    The drive DVDR speeds are: 12.
    The drive DVDRW speeds are: 12.
    E: JLMS DVD-ROM LTD-166S, Rev DS0E
    Audio CD in drive.
    Found 10 songs on CD, playing time 52:10 on Audio CD.
    Track 1, start time 00:02:00
    Track 2, start time 04:38:36
    Track 3, start time 10:24:03
    Track 4, start time 13:59:23
    Track 5, start time 17:46:57
    Track 6, start time 24:18:51
    Track 7, start time 31:53:17
    Track 8, start time 36:25:45
    Track 9, start time 41:58:34
    Track 10, start time 48:07:27
    Audio CD reading succeeded.
    Get drive speed succeeded.

    Installed itunes 6
    It works and burns
    New drop down menu on burning tab lists my old burner that is not in machine and it lists my new Benq burner
    All is well......

  • How to get the currrent month and year from a new date object

    If I create a new Date object as "d",
    java.util.Date d = new java.util.Date();how can I format the date to get the current Month as 'Jan' and the current year as '2008'. So if I have something like d.getMonth() gets the current month as 'Oct' and d.getYear() gets '2008'
    Thanks,
    Zub

    [Read the flamin' manual you must. Hmm.|http://en.wikipedia.org/wiki/RTFM]
    ~~ Yoda.
    Well no actually, he didn't say that, but he should have.
    Cheers. Keith.
    PS: Don't say that to a 7 foot pissedOff wookie when he's got his head stuck in a smoking hyperdrive, and you're being chased by a S-class battle cruiser... Ask Yoda how he got to be so short.
    PPS: It is the SimpleDateFormat you seek ;-)
    Edited by: corlettk on 14/10/2008 22:37 ~~ Also far to slow... but funny.

  • Copied Library to External Hard drive and iTunes cannot find

    I copied my iTunes library to an external hard drive last night and went into preferences and changed location and then deleted the original folder...now iTunes is empty... If I go onto hard drive and select a song it tranfers it into iTunes (and back onto computers hard drive)...obviously did something wrong...anybody have any suggestions on how to fix?

    Assuming you use the iTunes default settings where iTunes copied added items to your iTunes folder and organizes your library (meaning - everything is all self contained in the iTunes folder), then all you have to do is drag & drop your iTunes folder (not just the iTunes Music folder you find inside the iTunes folder) to the external drive and copy the entire thing.
    If you want to test that it worked or would like to actually start using it from that location instead, use these instructions when you start iTunes to point it to the new location...
    How to open an alternate iTunes Library file or create a new one
    http://docs.info.apple.com/article.html?artnum=304447
    If you are just testing, then close iTunes after you verify it works, and restart iTunes again with the same instructions and point it back to your internal drive (original) location.
    Additional info...
    Back up your iTunes library by copying to an external hard drive
    http://docs.info.apple.com/article.html?artnum=307074
    Cheers,
    Patrick

  • If I select transaction SU24 and I add the new object. Does it work?

    I am planning to include a new restriction criteria in a SAP standard transaction code.
    I have created a custom authorization object.
    Now I want to know that if I include this authorization object for authority check via SU24, will this work? That is including the authorization object through su24 makes it authorization relevent for transaction code or not?

    Bernhard, Thanks for the reply.
    Piyush Nandan

  • Lost all bookmarks, history, and ability to make new bookmarks and record new history

    that basically says it.
    also lost function of back and forward function and indication of website address . All of this is really pissing me off!

    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.com/kb/Bookmarks+not+saved#w_places-database-file

  • How do I replace my old external hard drive with a new larger external hard drive and move my music so itunes can find it?

    How do I move music from an old external hard drive to a new external hard drive and have itunes find it? 

    If you have a time machine back up of your current drive you can do this
    Shut down your computer, install the new drive. While the computer is off plug in the external hard drive that you have your time machine back up on. Hold Option key while the computer turnes on, let go of the option key once you get a grey screen. Shortly after you'll see  a list of bootable drives, select the one that has your time machine back up on it and boot into that drive.
    From there go into disk utility, format your new drive too, osx extended journaled ( I think, double check that, its been awhile since ive had to do this), hit format
    Exit disk utility and then you can use time machine to copy all your exisit data to the new hhd and then your pretty much done.
    There is also a program called Carbon Cloner that will do esentially the same thing however I've never uesed it.

  • Script to find specific font and copy to a new document

    I am working on a scripting solution to help break out files for production. What I need to do is search through a PSD, find any text objects that are in a specific font, and if they match, copy them to a new document. Can anyone help me with this? I've been able to make parts work, but I am very green, and could use a little bit of direction.
    thanks!

    Yeah so far I've been having trouble checking the layers, identifying the fonts, and the creating the new text object on a new file So pretty much the whole thing is broken at the moment.  Any help you could offer would be greatly appreciated. I'm just now really starting to learn javascript just to be able to automate photoshop.

  • External Hard Drive and Computer NOT recognizing IPod

    Can anyone please help me? I purchased an external hard drive to store all my songs instead of on my internal hard drive. I change the location of all my songs to the external hard drive and even import any new song there as well. But when I connect my IPod to my computer to update and import my new songs, my computer DOES NOT recognize the IPod. The only way my computer will recognize my IPod is if I disconnect my external drive first and then connect my IPod. But then I cannot import or update my IPod. This is driving me nuts. Any help is greatly appreciated. Thanks
    IPod 20G   Windows XP  

    Anyone find a solution for this yet??? I'm having a similar problem. I have an external drive but my tunes are on a partitioned drive on the internal. The external is off but when I go to enable disk use it keeps turning it off on me. When I have selected manually sync songs then it tells me that disk cannot be read from or written to. The computer never shows a drive for the ipod. This is really getting on my nerves!

  • My songs have all been duplicated.  All my music is on external hard drive and I want it to stay there.  Am using a new computer and thought I'd done all the required things for my library to show on iTunes 11.

    I'm using a new computer.  All my music is on an external hard drive and I want it to stay there.  Before installing iTunes on the new computer, I followed turingtest2's instructions as to the layout of all the iTunes folders (Itunes folder, Itunes Media, Music, etc...).  I also followed his instructions as to get all my music in iTunes on the new computer (but keeping all the media on the external drive).  Now my songs are all duplicated in my library (I normally have about 15,000 of them). They all play when I click onto them.  Also, I've lost all my playlists, and all the songs in the library are now ticked. I've already spent hours trying to sort this out, but can't seem to find a solution.  Help please!

    Hi turingtest2,
    Thank you for replying.  I've been looking at your posts about setting up iTunes using an external drive.  A bit of background info.  My old computer broke down, so I got a new one from work.  I've always kept my music files on my external drive (I have around 170GB of music).  I didn't follow the suggestions in the "migrate iTunes library" post because my old computer died on me.  However, I've looked at your posts about lay out of the iTunes folders.  Before connecting to iTunes on the new computer, I had reorganized my iTunes folder on my E: external drive, and created an iTunes folder which contains an iTunes Media subfolder.  The music files are in a Music folder, which is in the iTunes Media folder.  I've also put the following files in my iTunes folder: iTunes Library.itl, iTunes Library Extras.itdb, iTunes Library Genius.itdb, iTunes Music Library.xml, as well as sentinel.  I then followed the advice you gave bmw99 on 2 Nov 2013 at 9.58 (sorry, can't copy the exact answer). 
    Just to clarify:  I'd like to keep all my music media on the E: external hard drive (the computer hard drive is too small), and I'm aware i might never have my playlists back, and that all the songs in my library might be ticked.  However, I don't want my library to be duplicated. 
    I'm at work at the moment, but will be back home in about 10 hours, so I can be more specific about folders / files names. 
    I'm glad you picked up my message and greatly appreciate your help.
    Patrice

  • I have my iTunes Library on and external hard drive.  I have a new computer and want to use iTunes and KEEP my files on the external drive.

    My iTunes library is on an external hard drive, and I was able to access / add to the library from my windows laptop.
    I now have a new laptop, and want to be able to KEEP the library on the external drive while being able to use iTunes from the new laptop.
    I have selected "choose library" in iTunes, and have chosen the iTunes Library.itl file on the external drive.
    My media populates in iTunes on the new laptop version of iTunes, but when I click on a song iTunes says that it cannot locate the song.
    Your help is kindly appreciated!

    Thanks.  Were the settings shown in your last screenshot in force when you added the song that's shown on being on the C: drive?  It is also possible that at some point you ran iTunes with the external drive disconnected, in which case it will have defaulted to the library on the C: drive, or that you've run iTunes without explicitly selecting the library on the E: drive.  To make sure the latter is the case, hold down SHIFT while starting iTunes, then when you get this prompt:
    click on Choose Library..., navigate to the location of your current iTunes Library.itl file, and click Open.
    Part of your issue may that its not obvious where that current database file is located.  The folder layout on your E: drive isn't the one that's most easily managed - so its possible that the database file could be in:
    E:\xxxx\Files\iTunes
    E:\xxxx\Files\iTunes\iTunes
    E:\xxxx\Files\iTunes\iTunes 1
    I suggest that a lot of your issues can be addressed by reshaping your library into the reliable "portable" layout as described in tt2's Make a split library portable user tip.  Comparing your screenshot with the equivalent on my system (where I have a "well-formed" library on an external drive):
    where:
    there is just one iTunes folder with everything used by iTunes inside it
    all media is held within subfolders of the iTunes Media folder
    The way you have yours set up, where the iTunes Media Folder location is set to E:\xxxx\Files\iTunes rather than E:\xxxx\Files\iTunes\iTunes Media is probably why some of your media is not being located correctly - the extent to which iTunes can correctly resolve locations is, to an extent, reliant on the folders for the different media kinds (Music, Audiobooks, etc.) being inside the iTunes Media media folder.  One common misunderstanding (not helped at all by Apple's documentation!) is that the iTunes Media Folder location setting in Edit > Preferences > Advanced does not tell iTunes where to find anything; rather it determines where iTunes will put new additions to your Library, in conjunction with the Copy files to iTunes Media folder ... flag:
    I would definitely take the time to work through the steps to bring your library into the "portable" shape - there may be few remaining issues with broken links when that's complete but this will be much easier to fix if your library is in a more standard structure.

  • How to use DataSource and External transaction in 9ias?

    I'm working on a project that the application server needs to connect to over 100 databases.
    I'd like to use connection pooling and external transaction service defined in OC4J's Datasources.
    I wonder if anyone has an example of using datasource and external transaction service for OC4J.
    Right now, I export toplink project to a java source and do the initialization there manually but I don't know how to use Datasource to get connections and how to use the external transaction service in the java code for OC4J.
    I really appreciate you help.
    Wei

    Here is a fill in the blank example on how you could set this up through code:
    Project project = new MyProject();
    // alternatively, use the XMLProjectReader
    server = project.createServerSession();
    server.getLogin().useExternalConnectionPooling();
    server.getLogin().setConnector(new JNDIConnector(new javax.naming.InitialContext(), "jdbc/DataSourceName"));
    // the next line depends on the type of driver you want to use.
    server.getLogin().useOracleThinJDBCDriver();
    server.getLogin().useOracle();
    server.getLogin().setUserName("username");
    server.getLogin().setPassword("password");
    server.getLogin().useExternalTransactionController();
    server.setExternalTransactionController(new Oracle9iJTSExternalTransactionController());
    server.logMessages();
    server.login();

Maybe you are looking for

  • Location of DW CS3 files on a Mac

    I am running Dreamweaver CS3 on a Mac Pro running OSX 10.4 Tiger. I am about to upgrade to 10.5 Leopard and I want to do a clean install of all my CS3 products. I will have a full backup of my HD and I want to copy all my preferences for CS3 software

  • Best Practices for multiple authors using single project?

    We are having many issues, particularly with moving, renaming, and multiple check out warnings.  We have a single project with many authors and it seems like RH is not designed to work that way. There is an article in the RH devnet-archive in an arti

  • Non English BW Upgrade

    Hi Gurus, Please share your experiences on - When I am upgrading Non-English BW system ( from 3.x to3.5) what is special care if any should be taken or how is it different from normal BW (English) upgrade? thanks Vikash

  • Cluttered display on Vixia HF R400

    I'm looking to buy an HF R400, which is a very nice camera except for one quirk.  I've spent some hours looking at the one in the store and reading the directions, but can't solve this. In P mode the viewfinder is so cluttered with information that i

  • How do I get Messages to stop sending from my email address instead of my phone number?

    I've had several people tell me that texts I've sent from my iPhone have been showing up as <myemailadd>@mac.com instead of my phone number. It started doing that under iOS7. I don't want my email address sent with my phone-originated texts. I don't