It seems you cannot clone objects with attributes using lazy loading in JPA

I have an entity with an attribute using lazy loading:
@Entity
public class B {
@ManyToOne(fetch=FetchType.LAZY)
private A a;
@Entity
public class A {
Assume the following code:
A a1 = new A();
A a2 = new A();
B b1 = EntityManager.find(B.class, ...);
b1.setA(a1);
B b2 = b1.clone();
b2.setA(a2);
Now with lazy loading enabled I get b1.getA() == a2 instead of b1.getA() == a1. Moreover, the debugger displays the same value holder in b1 and b2 for the attribute a. It appears as if cloning does not make a (deep) copy of the value holder managing the attribute a.
How can I create a copy b2 of b1, such that the value holder managing a in b1 is a different object as the value holder managing a in b2?
Thanks, Thomas.

I have filed a bug to have this addressed in Oracle TopLink 11gR1. I would recommend you file a bug against TopLink Essentials in GlassFish or if you have a support contract report the issue to metalink to have the issue resolved.
If this is urgent I did try fixing the issue with a small helper method using some reflection. This method is simplified through its throwing of Exception. If you wish to use something like this I would recommend proper error handling.
     * Helper method for cloning an entity and fixing the woven value-holders to
     * complete a proper shallow cloning.
    public static Employee clone(Employee entity) throws Exception {
       Employee clone = entity.clone();
       // Now fix the cloned ValueHolder references
       Field[] fields = entity.getClass().getDeclaredFields();
       for (int index = 0; index < fields.length; index++) {
           Field field = fields[index];
           if (field.getName().startsWith("_toplink_")) {
               field.setAccessible(true);
               ValueHolderInterface vhi = (ValueHolderInterface)field.get(entity);
               Object value = vhi.isInstantiated() ? vhi.getValue() : null;
               field.set(clone, new ValueHolder(value));
       return clone;
    }Doug

Similar Messages

  • It seems you cannot charge me with my credit card for payment of February 2015. I dont know why. Please charge it again. I think it should be ok.

    it seems you cannot charge me with my credit card for payment of February 2015. I dont know why. Please charge it again. I think it should be ok.

    This is an open forum, not Adobe support... you need Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • Cannot Move Objects with Arrows - Ai CS5

    For some reason I cannot move objects with my arrow keys in Illustrator cs5. I can drag them and transform-move them but the arrow keys don't work. very annoying.
    Any clues as to what I can do to fix this?
    Thanks!

    Could happen if your keyboard increment value is zero or a very low number.

  • Why you cannot compress data while attribute change run is active?

    why you cannot compress data while attribute change run is active?
    Also, are there any prerequisites before running a compression.
    Will the aggregates get inactive after running compression?
    Regards,
    Simmi

    Hi Simmi,
    I'm not sure what are u looking for ..???? now u are asking whther if activation starts at the same time for 2 ODS,.. there wont be any problem if the activation starts parallelly..
    but these activation fails if the change run is running for the common master data. So make sure that when ever change run is running the corresponding master data will gets lock. thats the reason why u can see locks in rollup, compressions or any other parallel change runs....
    Hope this helps....
    Assign points if this helps.
    thanks
    Vishnu

  • I cannot send emails with pics using the stock email app on my new Droid Turbo, it holds them in the Outbox and won't send even if I move to Inbox and resend

    I cannot send emails with pics using the stock email app on my new Droid Turbo, it holds them in the Outbox and won't send even if I move to Inbox and resend

    First check to make sure you have data turned on and not just Wi-Fi. From reading your question you seem to be saying e mail is working just not attached photos. What size are the photos as some HD photos can't be sent. Your camera may be set at a very high picture size and you can go to settings and lower the size and that may solve your mailing problem.

  • You cannot create an Apple ID using a MobileMe account. If this is your email address, it is also your Apple ID

    I am dumping my Android and getting an IPhone to go along with my IPad, primarily because of the ICloud and the ease of synching all my mail, contacts etc. My original Apple ID was my gmail address. I now have the @me.com address when I put IOS 5 on my iPad. I want to dump gmail and just have one email address...the @me.com address. When I set up iCloud, I used the @me.com address. When I try to change my Apple ID to the @me.com address from the gmail address, I get this message "You cannot create an Apple ID using a MobileMe account. If this is your email address, it is also your Apple ID". Any ideas?

    I also have the same problem. Is there a solution?

  • Loading data with dates using SQL*Loader

    Dear everyone
    I am currently trying to load some data containing dates using SQL*Loader.
    For termination of fields I have been using ^ because I have some book titles which contain " and ' as part of their title. I found that the TO_DATE function did not seem to work using ^ instead of ". Would I be correct? I think the Oracle manual says that " must be used.
    After some Web research I eventually amended my control file to as follows:
    load data
    infile 'h:\insert_statements\22_insert_into_SCAN_FILE_INFO.txt'
    REPLACE
    into table SCAN_FILE_INFO
    fields terminated by "," optionally enclosed by '^'
    TRAILING NULLCOLS
    (scan_id, scan_filename
    file_format_id
    orig_scanning_resolution_dpi
    scanner_id, scanner_operator_id
    scanning_date "TO_DATE (:scanning_date, 'YYYY-MM-DD')"
    original_map_publication_id
    reprint_publication_id)
    A simple line of data is as follow:
    280001, ^1910 - London^, 270001, 400, 250001, 260001, "TO_DATE('2007-06-06', 'YYYY-MM-DD')", 200019,
    The final column being null.
    However when I attempt that I get the following error message:
    Record 1: Rejected - Error on table SCAN_FILE_INFO, column SCANNING_DATE.
    ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    If I change the scanning_date part to:
    scanning_date "EXPRESSION TO_DATE (:scanning_date, 'YYYY-MM-DD')",
    or
    scanning_date "CONSTANT TO_DATE (:scanning_date, 'YYYY-MM-DD')",
    I get the error message:
    Record 1: Rejected - Error on table SCAN_FILE_INFO, column SCANNING_DATE.
    ORA-00917: missing comma
    As soon as I do the following:
    scanning_date "EXPRESSION, TO_DATE (:scanning_date, 'YYYY-MM-DD')",
    or
    scanning_date "CONSTANT, TO_DATE (:scanning_date, 'YYYY-MM-DD')",
    I get too many values error message:
    Record 1: Rejected - Error on table SCAN_FILE_INFO.
    ORA-00913: too many values
    I also tested out scanning_date DATE "YYYY-MM-DD", but that just gave the same ORA-01841 error message as above.
    I must be doing something very simple which is wrong but I cannot figure it out.
    Kind regards
    Tim

    And why do you have scanning date as "TO_DATE('2007-06-06', 'YYYY-MM-DD')" in your infile? All you need is 2007-06-06. If you can not change infile generation code, use:
    load data
    infile 'h:\insert_statements\22_insert_into_SCAN_FILE_INFO.txt'
    REPLACE
    into table SCAN_FILE_INFO
    fields terminated by "," optionally enclosed by '^'
    TRAILING NULLCOLS
    (scan_id, scan_filename
    file_format_id
    orig_scanning_resolution_dpi
    scanner_id, scanner_operator_id
    scanning_date "TO_DATE(REPLACE(REPLACE(:scanning_date,'TO_DATE('),'''YYYY-MM-DD'')'), 'YYYY-MM-DD')"
    original_map_publication_id
    reprint_publication_id)SY.

  • Cannot move objects with Selection Tool

    Having problems moving a selcected with Selection Tool: the selection does not move.
    Also cannot isolate imported picture as it always seems to be selected, even when deselected: Selection Tool always activates first layer even though I'm on another layer
    Any new imported burshes i make up are not saved, even though file names shows up: only managed to save one brush
    I nearly awlays have to re select stroke width everytime I use selection tools or re open file.
    Are the problems due to compatibility issues with Mac OS and Illustrator CS4, as this new version is know to be very buggy in the industry.

    bottchichellee,
    Illy is Illustrator.
    I apologize for the unavailability of the site, owing to some mess by the webhost. This is an extract:
    Up to Illustrator 10, almost all the preference settings were included in the AIPrefs/Adobe Illustrator Prefs file, and almost all issues with corrupted settings could be solved by deleting or moving it; in some rare cases, moving or deleting the folder holding the settings was required.
    From Illustrator CS on, the preference settings have been spread over a number of files/subfolders so in many cases deleting the AIPrefs/Adobe Illustrator Prefs file is not enough: the easy solution is to move the whole folder rather than trying to figure out which file(s) may be corrupted; just deleting the folder without moving it first has proved fruitless in some cases.
    Therefore, the cure all consists of the following steps:
    1. Close Illustrator.
    2. Make a search including hidden files and folders and including subfolders for the folder holding the preference files; the name of the folder depends on the Illustrator version, and the position of the folder depends on the OS version. There is one folder for each version and for each user so it is important to find the relevant one.
    Up to version 10, the name of the folder is Adobe Illustrator [X],
    From version CS on, the name of the folder is Adobe Illustrator [X] Settings.
    [X] is the version number; up to 10, it is just a number, and above that the Creative Suite version number, CS, CS2, CS3, CS4, and so on, is used (the corresponding standalone versions still have simple numbers, CS is called 11, CS2 is called 12, CS3 is called 13, and CS4 is called 14, but the version numbers with CS are used in the folder name).
    3. Either:
    a) Create a subfolder and move all the contents into it; or
    b) Move the whole folder to a place where you can find it again, such as the Desktop.
    With both you may recover the contents of the folder by moving it back if the issue is not solved and get your preference settings back.
    a) requires creation of the subfolder, but it makes recovery easier, especially if you create a shortcut to the preference settings folder, and you can skip the search if/when corruption occurs again.
    You may delete the folder/contents subsequently.
    4. If you have Windows Vista, restart Windows. If not, continue to 5 without delay.
    5. Restart Illustrator, and see whether the issue is solved.
    If the issue is solved, and you wish to keep as many of your preference settings as possible, you may move the folder back and repeat 3) - 5) for groups/individual files/subfolders until you have found the corrupted one(s). You may also start by only moving the AIPrefs/Adobe Illustrator Prefs file.
    You may also see a terse version from ADOBE: Adobe Illustrator CS4 * About preferences.
    Scripts for cleaning out everything between uninstallation and reinstallation for versions CS4 and CS3:
    CS4 Clean Script, http://www.adobe.com/support/contact/cs4clean.html
    CS3 Clean Script
    I believe it is possible to get a refund, but there are some options still.

  • Overlap Buttons? Can you select 2 objects with one click?

    Hi I am trying to create a menu of a map for a client. They would like a text list of cities down one side and also dots over each city on the map.
    I have set the highlite groups to change the colour of the text but I would like to also set the menu so that when selecting the city in the the text area the coresponding dot over the city changes as well?
    As the cities are all ove the place and some quite close together i keep getting the buttons overlapping. Ive tried merging the layers so text and dot are together but it keeps overlapping and im not sure how, if i can, get it working?
    Product Version: 3.0.0.268
    DVD Devices Installed:
    HL-DT-ST DVD+-RW GSA-H53N (Firmware B104)
    Dell Precision PWS490 Intel Xeon Dual 5120 @1.86ghz 3.00gb RAM windows XP SP3 3TB raid storage
    Thanks in advance

    Hi Dave,
    The only way to do this with Encore that I know is to use a series of duplicate menus and the auto-activate feature.
    So when the audience navigates to a particular city's text, the auto-activate feature automatically executes a link to an exact duplicate of the menu they were just navigating, and displays the highlighted city text and a highlighted city dot. The dot won't actually be part of the button on the new menu, but it will look like it is.
    This technique involves careful pre-planning and a lot of linking work. It is easy to get lost in the links if you don't have a proper flowchart drawn on paper and if you don't use good menu-naming conventions.

  • Cannot resize object with the bounding box.

    I am using Illustrator CS4. When I move my selection tool to the white square on the bounding box for resizing, I am not getting the normal arrows that appear. When I click on the box and move the pointer the entire box and image move. This was working OK until about 5 hours ago.
    Thanks for any help.  BreBro1

    Are u able to see the bounding box ? It might be hidden. Can u please try this
    goto View > Show Bounding Box
    shortcut Crtl + Shift + B
    give it a try if this doesn't work I would suggest u to share a screenshot so I could help you
    good luck.

  • Basic Problems with Attributes and Data Loading

    Hi Specialists,
    I have a basic understanding Problem. I will explain it with a simple Example. I have to load Employee-Data from a file. For each Employee we have
    EmployeeNo
    EmployeeName
    EmployeeLanguage
    My Modelling:
    1 InfoObject Employee, with EmployeeNo as Key and EmployeeName as Text. For the EmployeeLanguage I create an additional InfoObject, in order to have an Attribute EmployeeLanguage at the InfoObject Employee. So far so good (I think).
    What kind of DataSources have I to create?? It is necessary to load the possible Languages first?? If yes, what kind of DS I have to choose, for loading only "English", "German", "Dutch". Attribute? Text?
    If not, the loading process is not possible, because one language exists more than one time in my flat file.
    Hope you can help me to see it clear.
    Thanks.
    Denise

    Hi Denise,
    I don't think you have to load all possible languages first. This is only necessary if you also want to load texts for EmployeeLanguage (example language german with texts "german", "deutsch", ...).
    Specify Employee as data target (in tab Master Data / Texts) and assign your InfoArea. There you will find your targets for texts and attributes, now create InfoSource for your file and assign update rules for both texts and attributes.
    Best regards,
    Björn

  • Generating XML with attributes using XSU

    Oracle document claims if the sql is:
    select empno as @empno from employee
    Using XSU to generate XML will produce and XML document with EMPNO as an attribute instead of element name. But this does not seem to work. There is an exception:
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Character '&' is not allowed in an XML tag name.</ERROR
    Is there anything wrong or is there a work around

    Oracle document claims if the sql is:
    select empno as @empno from employee
    Using XSU to generate XML will produce and XML document with EMPNO as an attribute instead of element name. But this does not seem to work. There is an exception:
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Character '&' is not allowed in an XML tag name.</ERROR
    Is there anything wrong or is there a work around

  • How to set an object in attribute using tags

    Hello.
    I know you can do this <% request.setAttribute("someName", Object); %>
    But i am wondering if there is a jsp , jstl tag which can do the same thing? Also where I can give the scope.
    I would like to do something like this <jsp:someTag name="someName" value=${variable} scope="request" />
    Thanks in advance.

    I think you can use
    <c:set var="articleList" value="${advertises}" scope="session" />But this doesnt work. Any ideas?

  • Why r we allowed to create String objects with & without using new operator

    While creating any object, usage of the new operator is a must...but only for the string object we can create it with and also without new operator how is it possible to create an object without using new operator.

    Because Mr. (Dr.?) Gosling is a kindly soul who realizes that programmers have deadlines and, when he designed Java, was not so rigid or unbending as not to realize that from time to time, certain shortcuts are warranted, even in a relatively pure language such as Java. The direct String literal assignments are a shortcut over using the new operator making Java programming (and execution; there's also a performance benefit) more streamlined.
    So look not the gift horse in the mouth, but simply bask in the simplification and ease on the eyes and directly assign your little literals to your heart's content.

  • Cannot video chat with someone using AIM software

    I tried to video chat with someone who was using the downloadable AIM software, and when they initiated the chat, nothing came up saying a video chat was requested, and when i tried to initiate it, a notification came up for them, they accepted, but nothing happened, video chat did not initiate, and on the top of my video chat screen it still said "waiting for response from ...". Anyone know what this problem is and how to fix it?

    Try these first steps
    http://discussions.apple.com/thread.jspa?threadID=1968438
    10:30 PM Thursday; June 17, 2010
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"

Maybe you are looking for

  • Payment Term changes  in Projects and AR

    Hi, Currently all our projects are based on single agreement. recently we had to change the payment term for a Customer. Our Receivables group made this change in AR. We were expecting all the Projects invoices would pick up this , when they are inte

  • BlackBerry Torch is No Longer Pairing with my Car

    My phone and car work working fine together recently it stopped. My Phone said it was connected but if I tried to make a call it would disconnect right away.. I tried deleting the device from my phone, and my phone from the car (Dodge Journey) And tr

  • Additional field in SAP Infoset - internal table

    Hi Gurus, I have invoices like: VBELN    Matnr     mtart 1234           Ek21    MCFE 1234           Ek33    MCFE 1234            Ek29    MCFE 1234           321       MRM1 1235          EK11      MCFE 1235           EK17      MCFE 3212           EK23

  • Frequency for random no generation between 0.1 and 1.0

    how can i create a array which stores the frequency of each random no i have generated. keep having different type error messages

  • Can't Find Download Link adobe creative suite 5.0 Design Premium

    I had to reinstall my system software so now I'm trying to reinstall my Adobe products. Problem is, I can't find a link to download Adobe Creative Suite 5.0 Design Premium. The links I have found are for version CS5.5 and my serial does not work with