[JPA]   @OneToOne doesn't set the ID of the relationship owner

Hi,
I have a problem. If there's a cascaded @OneToOne relationship between two entities and the relationship is of type @PrimaryKeyJoinColumn and I persist the inverse side, the owning side does NOT get a proper ID.
Here's an example:
Two tables:
CUSTOMERS
  (ID number(18) not null,
   NAME varchar2(50))
CUSTOMER_DATA
  (ID number(18) not null,
   CREDIT_CARD varchar2(50));The ID columns in both tables are primary keys.
There's a foreign key from CUSTOMER_DATA(ID) to CUSTOMER(ID).
So, I have two entities:
@Entity
@Table(name="CUSTOMERS")
@SequenceGenerator(name="customerIdSeq", sequenceName="CUSTOMERS_SEQ", allocationSize=1)
public class Customer {
     @Id
     @Column(name="ID", nullable=false)
     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="customerIdSeq")
     private Long id;
     @Column(name="NAME")
     private String name;
     @OneToOne(mappedBy="customer", cascade=CascadeType.ALL)
     private CustomerData customerData;
     public Long getId() {
          return id;
     public void setId(long id) {
          this.id = id;
     public String getName() {
          return name;
     public void setName(String name) {
          this.name = name;
     public CustomerData getCustomerData() {
          return customerData;
     public void setCustomerData(CustomerData customerData) {
          this.customerData = customerData;
@Entity
@Table(name="CUSTOMER_DATA")
public class CustomerData {
     @Id
     private Long id;
     @OneToOne
     @PrimaryKeyJoinColumn
     private Customer customer;
     @Column(name="CREDIT_CARD")
     private String creditCard;
     public Long getId() {
          return id;
     public void setId(Long id) {
          this.id = id;
     public Customer getCustomer() {
          return customer;
     public void setCustomer(Customer customer) {
          this.customer = customer;
     public String getCreditCard() {
          return creditCard;
     public void setCreditCard(String creditCard) {
          this.creditCard = creditCard;
}So, now I try to do the following:
     Customer cust = new Customer();
     CustomerData custData = new CustomerData();
     cust.setCustomerData(custData);
     custData.setCustomer(cust);
     cust.setName("OneToOne");
     custData.setCreditCard("1111-1111-1111-1111");
     em.getTransaction().begin();
     em.persist(cust);
     em.getTransaction().commit();And I get an exception:
     java.sql.SQLException: ORA-01400: cannot insert NULL into ("RMS"."CUSTOMER_DATA"."ID")Why does that happen? I set the relationship properly:
     cust.setCustomerData(custData);
     custData.setCustomer(cust);So, it seems logical that CUSTOMER_DATA.ID should automatically be assigned the same value as the one obtained for CUSTOMER.ID.
What else am I supposed to do?
Best regards,
Bisser

Just tried with the latest TopLink Essentials version (v2.1-b38) from here:
https://glassfish.dev.java.net/downloads/persistence/JavaPersistence.html
The same problem is still present.
It sure looks like a serious deficiency in the JPA spec. Why do I even need to specify a separate @Id basic mapping, if I have specified the @OneToOne and the @PrimaryKeyJoinColumn annotations in the relationship? They should be sufficient for finding out what the ID should be? The ID can be obtained from the inverse entity.

Similar Messages

  • I have two children each with an ipod which has FaceTime - I have the iphone 4s with FaceTime.  All of these devices are connected to itunes through the one account.  How do I set up the FaceTime on the two ipods so as it doesn't ring both of them?

    I have two children each with an ipod which has FaceTime - I have the iphone 4s with FaceTime.  All of these devices are connected to itunes through the one account.  How do I set up the FaceTime on the two ipods so as it doesn't ring both of them?

    I started to do that then it said that this will become their apple I.D or similar and then I thought that will disconnect them from the same iTunes?  I want them still on my iTunes as they are only young (8 and 10)?  Or have I got this all wrong and even if I do set them up with a different e-mail will they still be on my itunes?  For example if they want to purchase an App will it still go through my account even if they use their ipod?

  • How to I set an internal link in a PDF document using Preview?  After setting a link under the Tools/Annotations menu, the link doesn't work and no detailed instructions are provided.

    How to I set an internal link in a PDF document using Preview?  After setting a link under the Tools/Annotations menu, the link doesn't work and no detailed instructions are provided via the Help menu other than it showing the pull-down menu selection to make.

    No.  I am able to use the other features such as underlining, highlighting, adding rectangles and oval and save those changes.

  • Can I use a inputHidden for javascript values that doesn't set the value?

    I have a hiddenInput field for each row in a datatable so I can restore default values to a date field with a javascript function. I am getting conversion errors because I don't have the right setters in the backing object - and I really don't want to put them there - but I don't want the tag to set the values! Is there any way to just set a hidden value somewhere for each row of a datatable but not have it try to set the value? Thanks in advance!

    I just realised that won't work because all the HTML tags will have the same name, whereas I need the dynamically generated suffix that a dataTable assigns to every element in the row i.e. '_id34', so I can reference the value in the javascript and compare it to entered values. Any more ideas? I am having huge memory problems when I'm submitting my form too, using up 2GB of mem and then dying! I'm not sure what's causing it, because it doesn't get as far as my action method code before it dies! It works for smaller tables but I need to be able to handle ~20 users with tables 4x the size I can process now without running out of memory :( Any help would be really really appreciated!!

  • I can`t use apple store. my apple id needs my paswoord, to set the security questions, after I introduce the paswoord it askes for the paswoord again and again! it doesn`t work, and the paswoord is the right one. What can i do?

    i can`t use apple store. my apple id needs my paswoord, to set the security questions, after I introduce the paswoord it askes for the paswoord again and again! it doesn`t work, and the paswoord is the right one. What can i do?

    I have figured out already. Firstly please try:
    1) Installing iBooks on your iPhone via iTunes on PC/MAC
    2) Adjust the time of your iPhone to 6 months ahead (e.g. 2013 May)
    3) Close all apps currently running, clear Safari cache and history, sign out of Apple ID (Settings>iTunes & App Stores), reboot your device
    4) Open iBooks on your iPhone, download any 1 book
    5) System should prompt you to enter 3 security questions
    6) Enter your answer and click "Done" at bottom right part of your input keyboard (Do not press upper right button)
    7) Done!
    I cannot imagine the system has gone so stupid. Apple, please retify the problem ASAP.

  • Each time I open my Firefox browser, the tab from the last time opens. I have the browser set to open on my home page, not to the tab from the last time. I keep trying to save the setting for the browser to open on my home page but it doesn't.

    Each time I open my Firefox browser, the tab from the last time opens. I have the browser set to open on my home page, not to the tab from the last time. I keep trying to save the setting for the browser to open on my home page but it doesn't.

    Try to create a new profile as a test to check if your current profile is causing the problems.
    See "Basic Troubleshooting: Make a new profile":
    *https://support.mozilla.org/kb/Basic+Troubleshooting#w_8-make-a-new-profile
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
    If the new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
    See:
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox
    Do a malware check with some malware scanning programs on the Windows computer.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br /><br />
    *http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    *http://www.superantispyware.com/ - SuperAntispyware
    *http://www.microsoft.com/security/scanner/en-us/default.aspx - Microsoft Safety Scanner
    *http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    *http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    You can also do a check for a rootkit infection with TDSSKiller.
    *http://support.kaspersky.com/viruses/solutions?qid=208280684
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • MAC Mail:  I have 2 accounts set up.  I used to be able to add attachments to both accounts, but now I can only attach using 1 of the accounts.  The other one doesn't work.

    MAC Mail:  I have 2 accounts set up.  I used to be able to add attachments to both accounts, but now I can only attach using 1 of the accounts.  The other one doesn't work.

    Try unmounting the volume on your iMac using Disk Utility. Then mount it again. You may need to reboot the laptop or relaunch its Finder process (using the Force Quit window) after remounting the drive on your iMac. Remember that no process may be accessing any files on the drive you plan to unmount, or the unmount will fail. Unmounting and remounting an external drive on my iMac made it become visible on my MacBook Pro after it had disappeared.

  • Why when I open my password protected Pages document it doesn't require me to enter the password that I have set to see the document?

    When I open my Pages app and try to open my previously password protected document it doesn't require me to enter the password to see the document. It just takes me straight to the document like any other document that isn't password protected. Isn't this the point of having a document password protected so no one can see it without knowing the password? Am I missing something when I set the password in the first place? Thanks.

    When you set a password in Pages v5(.2), you are offered a check box to remember the saved password in your keychain. If you do not enable this check box, you will always be prompted locally for the document password. If checked, before opening the document, Pages queries keychain if it knows anything about the current local document security, and once confirmed, it simply opens the document without a challenge.
    To disable the keychain knowledge for the local document, you open the document, and choose File > Change Password… . Enter the current (old) password only, then select the Remove Password button. Now, you can use File > Set Password… again to set the password, and omit the Remember this password in my keychain option. The desired document password prompt will occur on your local (and remote) access.

  • When i'm in safari, if i hit command   to make the type bigger safari doesn't rememberthis setting after i close the site and reload it.  in chrome this happens automatically.  can i make safari remember my type size settings automatically?

    when i'm in safari, if i hit command  +   to make the type bigger safari doesn't remember this setting after i close the site and reload it.  in chrome this happens automatically.  can i make safari remember my type size settings automatically?

    That is normal Safari behavior.
    May be this will help.
    Safari > Preferences > Advanced
    Accessibility:   Never use font sizes smaller than
    Default is 9.    Click the downward arrow and select a larger font size.
    Put a check mark in the box to enable it.

  • I'm using Acrobat Pro 11. When printing an email to PDF most of the time it cuts off the text on the right margin. Setting look OK and I've moved things around on the email, but that doesn't seem to make any difference. Is there an Adobe setting I'm missi

    Like I said above, print to Adobe pdf and it wants to cut off the text on the right margin. I can't see to find a setting that changes this. Any ideas??

    OK, so I have now found that this is apparently normal for iTunes, to only accept mpeg 4 movie files, all the searching I did before I must have worded it wrong because I couldn't find anything about this, incredibly. Had been looking for why iTunes won't take all the files it previously did, like if it had been changed, and it hasn't, it's allegedly always taken only mpeg 4 files. Also I had been searching for why iTunes crashes every time I try and add/import anything but mpeg 4 files, and even sometimes with mpeg 4 files. That isn't normal, it's supposed to just do nothing apparently as I've just found out. So for these reasons I didn't find the answer despite my searching all over the web.
    So I guess that answers my own question now, but I'm still perplexed as to why I absolutely, definitely, without any doubt, had several hundred movies of a few different video file types loaded, accessible and playable in my iTunes library that everything here claims iTunes never accepted. It apparently shouldn't have been possible for me to have done this, but for probably 10 years it's been this way.
    Perhaps since I don't remember adding these files to iTunes anymore recently than maybe 6 or 7 years ago, the iTunes back then did accept all kinds of file types? Or could I have somehow had some video codecs or software that expanded the capability of my movie players like Quicktime Player that unwittingly also allowed iTunes to take those files as well? All I know is somehow it worked! So now my question is how did I have it working before, so that maybe I can make it work again.

  • Initializing with the console doesn't set indexes

    Hi,
    We want to change the basedn of a suffixe, from o=isp to o=Courrier,dc=domcomponent,dc=com. I exported my data using a db2ldif -U and modified my ldif with a sed. It seems that after I initialized my new suffixe with the console or the ldif2db.pl script, my indexes are not set. It takes many seconds (60) to receive the response of a basic ldapsearch. (e.g.:uid=tom) The db/Courrier/files has been generated during the initialization. After a reindex with the console (it takes 4 hours), the ldapsearch took 0 second to respond. How can I, index while initializing.
    I'm running version Sun ONE 5.2 (Sun-ONE-Directory/5.2 B2003.143.0020)

    Hi,
    Ive experienced the same sort of problem, but have sorted it using either db2index or the console to re-index after initialisation.
    According to the docs, re-initialisation should copy down indexes from the MAster server but this does not happen either.
    Regards,
    g8

  • The sound doesn't work.  It's set appropriately in settings, the volume is turned up all the way with the side buttons, but no volume.  When we try to play songs, it acts like it's going to play and then goes back to the play list.  Restored and still no

    It's set appropriately in settings, the volume is turned up all the way with the side buttons, but no volume.  When we try to play songs, it acts like it's going to play and then goes back to the play list.  Restored the device and still no sound.

    Try A and B
    (A) Restart iPad
    1. Hold down the Sleep/Wake button until the red slider appears.
    2. Drag the slider to turn off iPad.
    3. Turn iPad back on, hold down the Sleep/Wake until the Apple logo appears
    (B) Reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • When I first am looking at my newly uploaded photos in "Library", a box appears near the bottom of the photo that says "loading" (the photo looks good to me), then it is more "faded" and does not look as good.  Is there some setting on that I am not aware

    When I am first looking at my newly uploaded photos in "Library," a box appears near the bottom of the photo that says "Loading".  While it is loading, I usually think the photo looks "good".  After the photo is done loading, it looks more washed out.  Is there some sort of setting that I might have on (or that I need to turn on) so that this does not happen.  I have Lr4.  Thanks.

    Hi Tracy,
    There used to be a way to see if poster was new to the forum.., anyway - welcome to the forum.
    As I was alluding to, biggest differences in initial display are due to:
    * Camera calibration profile.
    * Auto-exposure/contrast settings (for which compensations have been auto-applied in camera, but not in Lightroom).
    So, choose a matching camera calibration profile (whether that's an option or not depends on your camera model - they're available for many but not all models) if you prefer one of them over "Adobe Standard" (the factory default profile).
    Also, your camera covers for underexposure due to non-optimal auto-exposure/contrast setting, Lightroom doesn't, so your options are:
    * turn it off in camera.
    * learn to compensate manually (or automatically via a plugin) in Lightroom.
    Of course, in addition to preferred defaults (alt-click big "reset" button in dev module), come up with some presets which are appropriate for your druthers and type of photography.. e.g. these will compensate Nikon ADL settings:
    http://www.robcole.com/LrForumSupport/ADL%20Compensations%20%282012%29.zip
    Cheers,
    Rob

  • Where does one set space after paragraph in the new Pages 5.0? It used to be under text in the Inspector in the previous version, but I just can't find it in this new version.

    Where does one set space after paragraph in the new Pages 5.0? It used to be under text in the Inspector in the previous version, but I just can't find it in this new version. Paragraphs seem to only be dealt with in styles, and the Formatting window for text doesn't seem to have the space after paragraph contrtol that the older Inspector had. What am I missing?

    Sorry I did this without looking:
    Side panel >Text > Style > Spacing > Turn the triangle > Before Paragraph/After Paragraph/
    This is the trouble with the Peeky Boo Contextual Interface that so many wiser heads than mine love to love.
    Peter

  • I have a Nano, where I changed computers and moved my library.  Now my nano doesn't recognize the location or the song on the nano.  How do I update my library so the nano will recognize.

    I  have an IPOD Nano.  I had it originally set up on another computer where I would down load my songs that I purchased from ITunes.  My Nano would sync up with my PC when I would plug it in.  I had to change computers, so I moved all my songs / library to my new PC.  I downloaded the ITunes process to my new PC and then purchased a song.  I saw the song in my download area of my PC under ITunes Media / downloads.  However, my nano would not sync as it is still referencing the prior location, which was on my old PC.  I moved the song directly to the Nano when it was plugged in.  I see the song on the Nano directory when I have it plugged in to the PC via the USB cable.  I even click on the song and I hear it play from the Nano on the PC.  However, when I go to look for the song directly from my song listing from the Nano music screen, it doesn't list he song or the artist as being on the Nano.
    I have tried to follow the online instructions for erase and sync the old library to the new, but that doesn't happen.  Any suggestions on what I may be doing wrong in moving from one PC to another.  Seems to me this should be a much simplier process.  But I find working with Apple products they are all harder to deal with.  I would appreciate your help.
    Mel

    I am not doing it in ITunes, but i did down load the song from ITunes.  I loaded the song on to my Nano, but in my menu selections it doesn't show the song or the artist in any search format.  However, when i plug in my nano to my PC I see the Nano library on my PC drive listings and that song and artist are there.  I can click on the song and it will play in Windows media on my work PC.  I did notice that the format for most all the songs in my library on my Nano are MPEG - 4 audio Files. 
    Thanks for your help, Mel

Maybe you are looking for

  • G570: CD/DVD and Hard Disk drives not recognized

    I have a Lenovo G570 laptop. It used to run fine until it started taking longer and longer boot into windows. Soon the computer would not boot into windows and instead try to repair windows, which would finish but never actually repair the computer.

  • Pass-through recording with Canon ZR25

    I have an older Canon ZR25.  Is it capable of pass-through recording from a VCR?  I can plug the VCR to the camera, and the camera to the computer via the firewire, but can't get anything to work.  Is my only option to actually record the VCR tape on

  • DVDs burned using iLife 06 are not recognized

    Hope someone has some advice for me. I have iLife 06 and have created a movie in iMovie. I sent it to iDVD to create the project and burn the DVD. So far, so good. But when the buring is complete, the DVD will not mount. It keeps getting ejected from

  • Contact Form Resetting after Submission Bug?

    Currently, when a contact form is submitted, all fields are cleared out and it appears that it returns to the Non-Empty state. However clicking in a field and then back out of it will make it go to the Empty state, as it seems like it should after su

  • Robohelp 9 v/s Robohelp 10

    What is the difference between Robohelp 9 and Robohelp 10? Which is better and why?