JPA OneToMany - ManyToOne Relation will not stored in DB

Hi,
I have the following problem:
I have two tables:
Logon
-username
-password
-company_id
Company
-Name
So Company has a OneToMany Relation to Logon and Logon a ManyToOne to company
I have created the following Entity classes:
class Logon{
    @ManyToOne()
    @JoinColumn(name = "COMPANY_ID",insertable=false, updatable=false)
    private Company company;
class Company{
    @OneToMany(mappedBy="company", cascade=CascadeType.ALL)
    private Collection<Logon> logons = new Vector<Logon>();
}And here is the code to insert the data.
        Logon logon = new Logon();
        Company company = new Company();
        logon.setCompany(company);
        company.addLogon(logon);
        EntityTransaction trans = em.getTransaction();
        trans.begin()
        em.persist(logon);
        em.persist(company);
        trans.commit();After that code I have an entry in table Logon and an entry in table Company.
But the field company_id in table logon is always set to 0 and not to the company's id.
The tables where not created from the entities. I have to work with an existing MySQL DB.
Does someone has an idea?
regards
Gerald

hi
i am using 2 tables. In parent table i am giving
@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="meterInfo")
@JoinColumn(name="METERID")
private List<MeterSub> meterSubs=null;
subtable i am giving
@ManyToOne(optional=false,targetEntity=com.nexant.mdm.dto.MeterInfoDTO.class)
@JoinColumn(name="METERID",nullable=false, insertable=false, updatable=false)
private MeterInfoDTO meterInfo;
i am inserting the data by using the test class like this:
MeterInfoDTO mi = new MeterInfoDTO();
mi.setMeterID(4);
MeterSub ms = new MeterSub();
ms.setMeterInfo(mi);
ms.setMeterData("meterData12");
ms.setMeterSubPk("103");
//ms.setMeterID(2);
List<MeterSub> set = new ArrayList<MeterSub>();
set.add(ms);
mi.setMeterSubs(set);
mi.setMeterName("Sample Meter NAme");
mi.setMeterTimeZone("TZ");
Last i am saving the data.
while inserting the data its giving the following error:
ORA-02291: integrity constraint (SYSTEM.SYS_C0010451) violated - parent key not found
Error Code: 2291
Call: INSERT INTO METERSUB (METERSUBPK, METERDATA, METERID) VALUES (?, ?, ?)
means its not taking METERID from parent and its giving 0. thats why the error coming like this.
Can any please help me to resolve this
Thanks
Shannu

Similar Messages

  • JPA Toplink OneToMany - ManyToOne Relation will not stored in DB

    Hi
    I am getting the error while inserting the data into Two tables by using the ManyToOne realation.
    i am using 2 tables. In parent table i am giving
    @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="meterInfo")
    @JoinColumn(name="METERID")
    private List<MeterSub> meterSubs=null;
    subtable i am giving
    @ManyToOne(optional=false,targetEntity=com.nexant.mdm.dto.MeterInfoDTO.class)
    @JoinColumn(name="METERID",nullable=false, insertable=false, updatable=false)
    private MeterInfoDTO meterInfo;
    i am inserting the data by using the test class like this:
    MeterInfoDTO mi = new MeterInfoDTO();
    mi.setMeterID(4);
    MeterSub ms = new MeterSub();
    ms.setMeterInfo(mi);
    ms.setMeterData("meterData12");
    ms.setMeterSubPk("103");
    //ms.setMeterID(2);
    List<MeterSub> set = new ArrayList<MeterSub>();
    set.add(ms);
    mi.setMeterSubs(set);
    mi.setMeterName("Sample Meter NAme");
    mi.setMeterTimeZone("TZ");
    Last i am saving the data.
    while inserting the data its giving the following error:
    ORA-02291: integrity constraint (SYSTEM.SYS_C0010451) violated - parent key not found
    Error Code: 2291
    Call: INSERT INTO METERSUB (METERSUBPK, METERDATA, METERID) VALUES (?, ?, ?)
    means its not taking METERID from parent and its giving 0. thats why the error coming like this.
    Can any please help me to resolve this
    Thanks
    Shannu

    Hi Tolls,
    i have one doubt while using the JPA Toplink.
    In my table it have primary key with 2 columns menas composite key acting as a primary key.
    So how i have to declare these fields in POJO class
    and also how to represent these Class and primary key in ONe to One realtion or Many to one relation.
    @ManyToOne(optional=true,targetEntity=com.nexant.mdm.dal.eo.Capability.class)
    @JoinColumn(name="CapabilityID",nullable=false, insertable=true, updatable=false)
    private Capability capability;
    here Capabity is the POjo calss and CapabilityID is the primary key , if in place of CapabilityID i have 2 keys acting as a primary key.
    So how can i represent this?
    waiting for ur valuble response :)

  • Data is not stored in database

    dear all
    i have creation page in that default 5 should be disaplyed like usd0.00
    as well as those items should be stored in db
    usd (came from functional currency came from set of books)
    when i take message styled text and set value to those it will not stored in db
    later i want to update those values
    Regards
    Sreekanth

    Hi,
    you can create a rowlayout and then create a rawtext and a messagestyled text in it...
    for raw text as the page loads you can set the text as "USD".
    and for message styled text you can simply use the code for currency formatting...
    so it will display as USD 0.00 and will store only 0.00.
    Thanks,
    Gaurav

  • Google, Yahoo, and very random websites will not open

    Google.com will not open, yahoo will not open and anything google- or yahoo-related will not open (including their search engines, which is killing me) as well as very random websites. Other websites open immediately. This is happening exactly the same on both Firefox and Safari.
    Mac OS 10.6.8. The other iMac in the house (OS 10.7.5) is working fine as well as our Macbook, iPad, and three iPhones. I believe the problem started after we changed Verizon modems and wi-fi networks, but I cannot be sure, and I don't understand why the other devices/machines would not also be effected. There is no spyware that I know of  installed on this problem machine. When I do a repair verification on the Utility Disk I get a lot of messages that read in different variations of the following: Warning:SUID file"System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contens/MacOs/Ar dAgent" has been modified and will not be repaired.

    It is the same with the other accounts on the machine, but not with any other Mac device in my house, including another iMac. I'm going to reword the question more clearly below, so that maybe others will have a solution. Thank you very much for your effort, Old Toad.
    Google, yahoo, and apple sites (including their search engines) will not open as well as a few random websites. Most other websites open immediately. This is happening exactly the same on both Firefox and Safari, so it does not appear to be a browser-specific issue. The operating system on the iMac is a Mac OS 10.6.8. The other iMac in the house (OS 10.7.5) is working fine as well as our Macbook, iPad, and three iPhones. I mention the other devices because I believe the problem started after we changed the Verizon modem and wi-fi network, but I cannot be sure, and I don't understand why the other devices/machines would not also be effected. There is no spyware that I know of installed on this problem machine.
    What I've done so far:
    Cleared all history on, and reset, both browsers.
    Run a "repair disk permissions" on the Utility Disk and I've received many messages that read in different variations of the following: Warning:SUID file"System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contens/MacOs/Ar dAgent" has been modified and will not be repaired.
    Cleared the caches in my hard drive Library and Users Library folders (the Internet is now faster for the sites that do work)

  • IPod will not play any music. Seems like it is in "Pause" mode.  No sound from either the head phones or internal speaker.  I have 418 songs stored and none will play.

    iPod will not play any music. Seems like it is in “Pause” mode.  No sound from either the head phones or internal speaker.  I have 418 songs stored and none will play. I have tried resetting, turning on and off the iPod, etc. but to no avail.

    Try restoring from backup. Next would be a restore to factory defaults/new iPod.

  • I cant download a new tv episode because itunes says the disk is full that it is being stored on....however when I deleted many shows from my library it still will not download.....I went to my desktop and tried to empty my recycle bin and the empty recyc

    I cant download onto my computer an episode I purchased because when I hit download it says that the disk I am attempting to tranfer to is full.....however iy had no problem down loading another show....(Jon Stuart) So I went to my library where I see my shows stored and deleted MANY and when I tried again to download ---I got the same message to full......I tried to empty the recycle bin on my desktop thinking it was holding too much but the choice to empty is not darkened so it will not empty....can ANYONE help?

    Therefore, t there any way to just completely delete all the old backup data out of my Time Capsule from my prior Mac Laptop?
    Here is how to do this:
    Open Macintosh HD > Applications > Utilities > AirPort Utility
    Click Manual Setup
    Click the Disks icon at the top of the AirPort Utility window
    Click the Disks tab below the icons
    Click Erase
    The "Quick Erase" option will only take a moment or two
    Now you can backup your MacBook Pro. If you connect an Ethernet cable from the MBP to one of the LAN <-> ports on the TC, the first backup will go 3-5 times faster than wireless.
    Once you have the first backup done, you can use wireless for subsequent backups since they will only take a few minutes

  • I opened my iPhoto library today which was stored on an external hard drive and several of my videos now will not play. The weird thing is that each file shows a duration of 1 second and when I open them it just shows one frame. What the

    I opened my iPhoto library today which was stored on an external hard drive and several of my videos now will not play at all. The weird thing is that each file shows a duration of 1 second and when I open them it just shows one frame. What the !&%$#@ Where did my original video files go?

    Sounds like a good plan, you can never be to safe and having a second External HD is safer than one.
    The only thing that I would do different, is setup the 3T as my TimeMachine Backup and then erase and move my Photos, Videos and perhaps even iTunes Media to the 1T. That way you will have room to backup both the Internal Hard Drive and the 1T External Hard Drive to the 3T using TimeMachine.
    Take your time, study and use the > Time Machine - Frequently Asked Questions if you get stuck or aren't sure how to make the move.
    Also see > iPhoto: How to move the Library folder to a new location
    iMovie ’08: Storing or moving your video library to an external hard disk
    and >  iTunes for Mac: Moving your iTunes Media folder

  • Is there any way that I can put the 600 songs that are stored on my old PC onto my new PC?  My iPod has the 600 songs on it but my iTunes will not let me add the songs onto the iTunes on the new computer.

    Is there any way that I can put the 600 songs that are stored on my old PC onto my new PC?  My iPod has the 600 songs on it but my iTunes will not let me add the songs onto the iTunes on the new computer.

    Yes.
    You should have copied everything from the old computer to the new one.
    Type "move itunes library" into the google search bar

  • Is there any possible way to speak to a person about fixing my firefox browser? It will not open and I do not want to lose the information stored there.

    My firefox browser will not open, so I can not try most of the solutions recommended. I do not want to lose stored information such as bookmarks and pass codes so would unstalling and reinstalling cause me to lose that information? I need to speak to a person to help with this, but do not know how to go about it. Should I be contacting Norton or Mozilla?

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. [[Troubleshoot Firefox issues using Safe Mode|Firefox Safe Mode]] is a troubleshooting mode that temporarily turns off hardware acceleration, resets some settings, and disables add-ons (extensions and themes).
    If Firefox is not running, you can start Firefox in Safe Mode as follows:
    * On Windows: Hold the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac: Hold the '''option''' key while starting Firefox.
    * On Linux: Quit Firefox, go to your Terminal and run ''firefox -safe-mode'' <br>(you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    When the Firefox Safe Mode window appears, select "Start in Safe Mode".
    :[[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, theme, or hardware acceleration. Please follow the steps in the [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]] article to find the cause.
    ''To exit Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    When you figure out what's causing your issues, please let us know. It might help others with the same problem.

  • HT4623 MY replacement iPhone 5 will not play my music stored on the phone on the music app that comes with the phone.  It shows the albums and artist but the music will not play.  How do I get the app to work correctly.  It works on my iPad and my wifes p

    help me to play my music on the music app that comes with the iphone 5 .  My replacement phone will not play my music stored on it.

    Anybody have anything for me?

  • HT2470 My Finder will not open. I cannot access any of my inforamtion that is stored on my computer. Not even on websites that i need pictures for. How do I fix this?

    My Finder will not open and i am on an iMac. I cannot see any of my information please help. I need my documents for websites also.

    Launch the Console application in either of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ If you’re running Mac OS X 10.7 or later, open LaunchPad. Click Utilities, then Console in the page that opens.
    Step 1
    Enter the name of the crashed application (Finder) or process in the Filter text field. Post the messages from the time of the last crash, if any — the text, please, not a screenshot.
    Step 2
    Still in the Console window, look under User Diagnostic Reports for crash reports related to the process. The report name starts with the name of the crashed process, and ends with ".crash". Select the most recent report and post the contents — again, the text, not a screenshot. For privacy’s sake, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)

  • My settings state that my "notes" will be stored to my Yahoo account but when I go to my Yahoo account I can't find my notes.  Are my notes being 'backed up" at Yahoo?

    My settings state that my "notes" will be stored to my Yahoo account but when I go to my Yahoo account I can't find my notes.  Are my notes being 'backed up" at Yahoo?

    Yes. If your default account for notes is Yahoo, they should be saved somewhere in yahoo. Usually I think it's just a folder titled "notes". At least that's how my gmail is.

  • Dan from iCloud Tech Support says that documents such as .pdf, .doc, .xls, etc. will NOT be stored on iCloud!  Huh???

    Called Tech Support because of 2 problems:
         1. Several of my documents have disappeared.  This includes some .pdf, .doc, and .xls files.
         2. Others are old copies of files that were updated, but all my changes were lost.
    Was informed by Dan in Tech Support that "documents will not be stored on iCloud."  He explained further that Word, Excel, PDF, etc. will not be stored on the Cloud--only music files, Pages, iPhoto, etc. will be.
    Is this true?  If so, this is stunningly bad.  And if it is true that iCloud isn't going to store documents, then why did it touch (i.e. lose, revert) them in the first place??  So all document storage will be on local or external drives now? 

    Dan is not entirely correct.
    If you install Goodreader this app WILL allow those documents to be stored on your icloud account within a specially created Goodreader container.
    Apple do allow third parties to use the conduit between desktop and iOS apps,however only a few third parties have implemented this todate..
    What icloud is NOT is unlimited remote storage,its more rather a syncing conduit.
    If you are looking at an idisk replacement do try Dropbox for that.
    Personally I employ BOTH methods in parallel at the moment as icloud remains very much a work in progress .
    I will probably transfer more to using the icloud route when the next desktop version of Pages is released and hopefully incorporates built in icloud sync functionality.The current requirement to utilize a web browser on your desktop to upload/download is a clutch !
    What does icloud do
    1 Sync photo images across iOS devices and with iPhoto or Aperture 3 on your Mac or with your Pictures folder in Win7
    2 Combines calendars between iOS and Mac Osx or  Outlook on Win7
    3 Combines Address book between ios and Mac OSx or Outlook on Win7
    4. Sync iWork- Documents in the cloud (Pages Numbers and Keynote) across iOS devices and upload/download to Mac or PC via icloud.com in web browser.
    5.Use find my iPhone/iPad/mac security functionality
    6.Remote backup of iOS devices.
    7. ITunes in the cloud (Stores all your music in icloud) plus subject to subscription iTunes match.
    8.ios app sync across devices.
    Plus new in 2012
    Invite friends to view photos and or movies via email link.
    What it do not do
    Allow you to drag and drop any file type from Finder/Explorer to remote storage (a la idisk or Drop box)- This may change as the service develops.

  • TS4036 My camera roll will not restore from iCloud after updating my iPhone 4 to iOS 6. It shows I have 1.7 gigs of photos stored on camera roll but none are appearing on my phone. Everything else restored from iCloud.

    My camera roll will not restore from iCloud after updating my iPhone 4 to iOS 6. It shows I have 1.7 gigs of photos stored on camera roll but none are appearing on my phone. Everything else restored from iCloud. When I go to iCloud.com my photostream is not there.

    A response I put together from another post. Also going into iTunes and choosing to sync phone to iCloud then back "this computer" sometimes works.
    First thing.. Stop where you are. Don't try to sync, update, hard reset, iCloud... Just stop.
    Check on your phone under 'SETTINGS' 'GENERAL' USAGE'. It should show some value for PHOTOSTREAM. Also, connect to iTunes and you will notice at the bottom of your phones summary page that there is a large amount of 'OTHER' data.
    I used third party software called iExplorer (formerly iPhone explorer). In this program you select 'MEDIA FOLDER', then 'DCIM'. In the various apple folders (IE: 101APPLE) you should be able to preview your photos and copy them to your desktop.
    From there sync them back to your device through iTunes or whatever method you use.
    There is a simpler solution I'm sure, which may involve using iExplorer to delete some .plist files then restart the phone and let it rebuild. I'm going to try it myself AFTER I've finished copying all the photos to my MAC
    Hope this helps.

  • TS1702 My pages has been stuck and will not open. Just says it is installing. I have tried several to no avail. I could reload but i want the information stored.

    My pages has been stuck and will not open. Just says it is installing. I have tried several times to open it, to no avail. I could reload for $9.99 but i want the information stored.
    Thanks,
    Terrance

    Thanks for this mha007 - I can now open FF with a new profile. Can I copy my settings from the old profile or will this bring over the same problem, maybe a corrupt file. If it would bring the same problem, is there any way I can check which file is corrupt, apart from taking them over one by one?

Maybe you are looking for

  • Install dialog box absent after PSE 13 download to Win 8.1 PC: which Set-up.exe to run?

    PSE 13 downloaded to a Windows 8.1 PC (64 bit OS) then Windows File Explorer opened showing the contents of 'This PC\Downloads\Package', namely two folders '32 bit PhotoshopElem13'and 'PSE 13' having similar contents. There is no guidance as to wheth

  • How to find size of bundle?

    hi all, i am making a vi in which the input is a bundle containing unknown number of elements (string and double 1d and 2d arrays), i want to unbundle it and then write in matfile format, i need to know how many elements and the type of each element

  • Failover Cluster disk failed on a VM.

    Hello, I tried to create a Failover cluster node on a VM (with a virtual disk with fixed size). All the step are ok except disk storage Add. When I try to Add a disk, the following error appears : Status : Failed. Information : Incorrect function. Er

  • Can't update firmware on WAP2000

    I have a working WAP2000 that won't accept the 2.0.3.4 upgrade file.  After selecting the file and pressing the UPDATE button, I receive the following error: This webpage is not available. The webpage at http://192.168.254.246/upgrade.cgi might be te

  • Simple-ccsm build error.

    G'evening everyone, I have been trying to install simple-ccsm from AUR several times, yet get a build error each time. This is the error: ==> Starting build()... Traceback (most recent call last): File "./setup.py", line 108, in <module> proc = subpr