How to save a record with null foreign key?

Dear all,
Most articles show non-nullable foreign keys; but now I've got a problem with nullable foreign keys.
With this simple example: an employee has zero or one manager.
in manager object:
@OneToMany(cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}, mappedBy="manager")
private Collection<Employee> employees;
in employee object:
@ManyToOne
@JoinColumn(name="manager_id")
private Manager manager;
when updating an employee record, i may use a selectOneMenu to pass a manager id of "0", I expect toplink to save a null manager_id in the employee record; but i tries to create a new manager object of id="0" (i.e. insert a new manager record instead)
the code i use to save an employee is like this:
em.getTransaction().begin();
em.merge(employee);
em.getTransaction().commit();
What's the correct way to save the employee record with a null manager_id column?
Could someone help?
Thanks a lot!
AK

But could you give me some pointers on how could I do
that from the web UI level?Got it. You want to select "nothing" and then set the object reference to that. I can't help you on JSF but how do you lookup the selected object behind the scenes? If you use entityManager.(Employee.class, 0) then you should get back null if there is no Employee with id=0.
--Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to retrieve unique records with more than one column

    I have a table sps_prod as described below -
    POGNAME VARCHAR2(1500)
    INDEX#VERSION VARCHAR2(200)
    POG_MODEL_STATUS VARCHAR2(100)
    POG_LAYOUT_TYPE VARCHAR2(500)
    POG_MARKET_SPECIFIC VARCHAR2(500)
    POG_CONTACT_NUMBER VARCHAR2(100)
    AREA_SUPPORTED VARCHAR2(500)
    POG_COMMENTS VARCHAR2(1500)
    POG_FOOTER_COMMENTS VARCHAR2(1500)
    POG_ELECTRICAL_LIST_1 VARCHAR2(1500)
    POG_ELECTRICAL_LIST_2 VARCHAR2(1500)
    POG_CARPENTRY_1 VARCHAR2(1500)
    POG_CARPENTRY_2 VARCHAR2(1500)
    INSTALLATION_INSTRUCTION_1 VARCHAR2(1500)
    INSTALLATION_INSTRUCTION_2 VARCHAR2(1500)
    FIXTURE_REORDER_NUMBER VARCHAR2(200)
    FIXTURE_ID VARCHAR2(200)
    FIXTURE_NAME VARCHAR2(500)
    FIXTURE_IMAGE VARCHAR2(500)
    PART_REORDER_NUMBER_9 VARCHAR2(500)
    PART_FIXTURE_ID_9 VARCHAR2(500)
    PART_FIXTURE_NAME_9 VARCHAR2(500)
    PART_FIXTURE_IMAGE_9 VARCHAR2(500)
    UPC VARCHAR2(50)
    ITEM_NUMBER VARCHAR2(50)
    DESCRIPTION VARCHAR2(700)
    MERCH_TYPE VARCHAR2(20)
    HEIGHT VARCHAR2(100)
    WIDTH VARCHAR2(100)
    DEPTH VARCHAR2(100)
    CREATE_TS DATE
    There are 4 millions records in it and many with the same combination of POGName,Index#Version,POG_Model_Status,POG_Layout_Type,POG_Market_Specific, POG_Contact_Number and Fixture_Name. How do I retrive records with all the columns above but with unique fixture_name and reorder_number combination. There are no keys defined on the table.
    I guess this is a simple problem but the fact that I am trying to retrieve all the columns is stumbling me.
    Thanks in advance.

    Hi,
    Sanders_2503 wrote:
    ... There are 4 millions records in it and many with the same combination of POGName,Index#Version,POG_Model_Status,POG_Layout_Type,POG_Market_Specific, POG_Contact_Number and Fixture_Name. How do I retrive records with all the columns above but with unique fixture_name and reorder_number combination. I don't see a column called reorder_number. Do you mean fixture_reorder_number or part_reorder_number_9?
    So you want only one row for each distinct combination of fixture_name and some other column (I'll assume that's fixture_reorder_number). Does it matter which row? They won't necessarily have the same values for the other columns.
    The query below returns the one with the first pogname (in sort order):
    WITH     got_r_num     AS
         SELECT  pogname, index#version, pog_model_status, pog_layout_type
         ,     pog_market_specific, pog_contact_number, fixture_name
         ,     ROW_NUMBER () OVER ( PARTITION BY  fixture_name
                                   ,                    fixture_reorder_number
                             ORDER BY        pogname
                           )         AS r_num
         FROM    sps_prod
    SELECT  pogname, index#version, pog_model_status, pog_layout_type
    ,     pog_market_specific, pog_contact_number, fixture_name
    FROM     got_r_num
    WHERE     r_num     = 1
    ;If there happens to be a tie (that is, two or more rows with the same fixture_name, fixture_number, and first pogname) then one of the will be chosen arbitrarily.
    Instead of "ORDER BY pogname", you can ORDER BY any other columns or expressions, but you must have an analytic ORDER BY clause. You can make it "ORDER BY NULL" if you really want to pcik an arbitrary row.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data (or a couple of examples of acceptable results).
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • How to Save Multiple Records In Data Block

    Hi All,
    I Have Two Blocks --> Control Block,Database Block
    Please Any Idea How to Save Multiple Records In Data Block when User changed Data in Control Block.
    Thanks For Your Help
    Sa

    Now i have to use each record of control block(ctl_blk) as where condition in data base block(dat_blk)and display 10 records from database table.>
    Do you want this coordination to be automatic/synchronized or only when the user clicks a button or something else to signal the coordination? Your answer here will dicate which trigger to put your code in.
    As to the coordination part, as the user selects a record in the Control Block (CB), you will need to take the Key information and modify the Data Block's (DB) "DEFAULT_WHER E" block property. The logical place to put this code is the CB When-New-Record-Instance (WNRI) trigger. You code will look something like the following:
    /* Sample WNRI trigger */
    /* This sample assumes you do not have a default value in the BLOCK WHER E property */
    DECLARE
       v_tmp_dw    VARCHAR2(250);
    BEGIN
       v_tmp_dw := ' DB_Key_Column1 = '||:CONTROL.Key_Column1||' AND DB_Key_Column2 = '||:CONTROL.Key_Column_2;
       Set_Block_Property('DATA_BLOCK', DEFAULT_WHER E, v_tmp_df);
       /* If you want auto coordination to occur, do the following */
       Go_Block('DATA_BLOCK');
       Execute_Query;
       /* Now, return to the Control Block */
       Go_Block('CONTROL_BLOCK');
    END;
    The Control block items are assigned with values in Form level (Key_exeqry).If your CD is populated from a single table, it would be better to create a Master - Detail relationship (as Abdetu) describes.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • How to save a png with a straight or fat alpha?

    Long story short, work in broadcast and a new piece of gear prefers png files.  I know how to save png's with a transparency, that's not the problem.  What I don't know how to do or if it's possible is to save them with a straight or fat alpha.  Right now we feather or extend the edges out past the alpha of say a logo and save it as a tif, psd or .tga.  That way once it's keyed over video or whatever, the edges look good, no black bad edging.... this makes sense, probably not explaining it very well.   But switching to png files I have no idea how to make a straight or fat alpha since it sees transparency.  I mean if I feathered out the edges, a png will see that correct, since there's no alpha??
    I hope this makes sense ?

    Chris, this is probably the answer I seek "PNG always saves with straight color - that's how the PNG spec defines it." 
    I admit my explanation was a bit weak and I understand PNG only supports transparency, which is not an alpha,  and the apps aren't treating them wrong....I just couldn't formulate an intelligent question and explain it, my bad.
    After thinking about it I don't think using a PNG will work. RIght now for broadcast gear/applications if we don't fill the transparent and semi-transparent areas of an image with the colored part of the image, we usually end up getting a dirty key/matte or a lot of fringing.  So when using a .tif or .tga that reads an actuall alpha, we can fix the issue by doing what I described.  In fact we use a quick little plugin from flaming Pear called "Solidifty" to speed up the process http://www.flamingpear.com/download.html .  With that said, I know we can't do the same steps with a png because it only sees transparency, but I guess I was wondering if there was a work-around or a trick to fix that issue.  I could be wong, but doesn't a png save with white ?
    But again, as I thought about it, I think i'm asking for something it's not meant to do, but I thought I'd ask anyway.
    Thanks Chris, does this make more sense or more confusing?  The bottom-line is I don't think it will work.

  • How to save a flash with .SWF

    Hi, I have the 'Adobe Flash CS3 Professional', and I want to
    know if you could tell me how to save a flash with .SWF.
    When I want to create a new project, I can chose between nine
    types of documents, and I want to make a flash for a website. What
    type of document would you chose if you were me ?
    I can't write the name of the diferent types of documents,
    because I have this programme in Spanish.
    Can you help me ?
    Thank you

    FLA is the native source format - make your movie and then
    publish to SWF -
    you can not create an SWF initially - SWF is the
    exported/published format
    of your FLA>
    "Marti_17" <[email protected]> wrote in
    message
    news:gioa0k$otm$[email protected]..
    > Hi, I have the 'Adobe Flash CS3 Professional', and I
    want to know if you
    > could
    > tell me how to save a flash with .SWF.
    > When I want to create a new project, I can chose between
    nine types of
    > documents, and I want to make a flash for a website.
    What type of document
    > would you chose if you were me ?
    >
    > I can't write the name of the diferent types of
    documents, because I have
    > this
    > programme in Spanish.
    >
    > Can you help me ?
    > Thank you
    >
    >

  • How to save a photo with a password on a mac

    how to save a photo with a password on a mac

    http://osxdaily.com/2012/08/12/encrypt-folders-mac-os-x/
    Note: I have never tried this.
    Best.

  • How to save a graph with some parameters on it?

    hi
    my application involves analysis of data and plot a graph of analysed data, how to save graph along with analysed data in a file otherthan labview?

    Well, it sounds like you are wanting a picture of the graph, yes? If so there are two ways of getting it. First there is a VI method (Get Panel Image) that lets you get an image of the entire screen, and then there is a control method (Get Image) that lets you get an image of just the front panel object that you are interested in.
    The help file entries for either method provides added detail on how to uses these methods to save a picture of your data.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Table with n foreign key vs n tables or n foreign key vs 1 table?

    Hi,
    we have a scenario with n tables containing some attributes one table for one category of attribute (es: color, role, type, etc..) of a principal entity and 1 table for the principal entity with n foreign keys vs every attribute table.
    Some propose to create a unique table called attributes in which put every attribute with an attributetype for each record.
    My question is: the principal entity will have n foreign keys vs the same attribute table. Is this perfomant? which is the best solution?
    Thanks in advance.
    v.

    >
    we have a scenario with n tables containing some attributes one table for one category of attribute (es: color, role, type, etc..) of a principal entity and 1 table for the principal entity with n foreign keys vs every attribute table.
    Some propose to create a unique table called attributes in which put every attribute with an attributetype for each record.
    My question is: the principal entity will have n foreign keys vs the same attribute table. Is this perfomant? which is the best solution?
    >
    Ask those 'Some propose' how a foreign key to the 'same attribute table' will prevent the WRONG value from being used for a column.
    1. Principal entity has a column for 'color' and a column for 'role'.
    2. There are FKs on the 'color' column and the 'role' column that both point to the 'same attribute table'
    3. Legal values for 'color' are: 1, 2, 3
    4. Legal values for 'role' are: 10, 20, 30
    What prevents someone from updating the 'color' column to a value of 20?
    Ask those 'Some propose' how your one attribute table will store attributes that are of different datatypes.
    1. 'color' uses numbers: 1, 2, 3
    2. 'type' uses strings: 'type1', 'type2', 'type3'
    3. 'holiday' uses dates: 12/25/2013, 01/01/2014
    How do your 'Some propse' plan to store ALL of those values in one column? They are likely to say they will use VARCHAR2.
    Ok - so how do you keep someone from updating 'holiday' to a value of 'type2' or a value of '3'?
    You can't easily validate the data to begin with and you can't easily prevent 'dirty' data from getting into the system.
    You also can't easily explain to ANYONE, for example new developers, how to properly use and maintain the table.
    I haven't heard you mention even ONE potential benefit to doing things the way that 'Some propose'. So - DON'T DO THAT!

  • Duplicate record with same primary key in Fact table

    Hi all,
       Can the fact table have duplicate record with same primary key . When i checked a cube i could see records with same primary key combination but the key figure values are different. My cube has 6 dimentions (Including Time,Unit and DP) and 2 key figures. So 6 fields combined to form the composite primary key of the fact table. When i checked the records in se16 i could see duplicate records with same primary key. Ther are no parallel loading happening for the cube.
    BW system version is 3.1
    Data base is : Oracle 10.2
    I am not sure how is this possible.
    Regards,
    PM

    Hi Krish,
       I checked the datapacket dimention also. Both the record have same dimention id (141). Except the Keyfigure value there is no other change in the Fact table record.  I know this is against the basic DBMS primary key rule. But i have records like this in the cube.
    Can this situation arise when same records is there in different data packet of same request.
    Thx,
    PM
    null

  • Reducing time while Filtering Out New Records with the Same Key

    Hi Experts,
    I have an issue .. I am trying to load data into 0MATERIAL . While loading via DTP the step u201CFilter Out New Records with the Same Keyu201D   takes much time for processing . For each datapackage it is taking around 30 minutes to filter out new records with the same key .  While for other master data it hardly takes 5 minutes.
    Any pointers how to reduce the timeu2026
    Thanks in advance
    Sam

    Hello,
    No there is no need to do that change then.
    Can you tell me are you doing a full load daily to 0MATERIAL object.
    why dont you use delta.
    Also if the DTP is of type FULL, then are you deleting the previous PSA requests.
    Maybe you can ask the basis guys to check with a trace what is really happening on the DB side during this 30 mins and then maybe we can find the needed fix.
    Regards,
    Shashank

  • How to identify tables use currency as foreign keys?

    Currently we have identified some currencies that needed to updated to ISO values and others as obsolete(eg. some EURO countiries set to EUR) in ECC
    So my question is how to efficiently locate those foreign keys tables in ECC?
    Thx and Best Grds
    David

    I do not think I fully understand your question but I will give it a shot.
    If you are trying to locate a foreign key, then proceed as follows.
    1.  Transaction Code: SE11
    2.  Enter the table in question.  For example BSEG
    3.  Select a table. For example BUKRS or KUNNR
    4.  Click on Foreign Keys.  The symbol or icon is a key with an arrow pointing down. It is before Srch Help.
    5. A screen will pop-up with the foreign key fields and tables where you can you the CHECKTABLE.
    Or enter table using SE11: GLPCT
    2.  Select RTCUR
    3.  Click on Foreign Keys
    3.  In the pop-up screen,  double click on TCURC in the check table field.
    Hopes the above provides you with a clue.
    Elias
    Edited by: Elias Akorli on Dec 7, 2009 2:29 PM

  • Had Photoshop Elements 12 on my other Mac that recently got smashed, new one has no CD drive. How do I install Elements with my product key? Purchasing an external CD drive is not an option at this time after forking over the 2500 for the new Mac...

    Had Photoshop Elements 12 on my other Mac that recently got smashed, new one has no CD drive. How do I install Elements with my product key? Purchasing an external CD drive is not an option at this time after forking over the 2500 for the new Mac...

    Downloads available:
    Suites and Programs:  CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4 | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  12 | 11, 10 | 9, 8, 7
    Photoshop Elements:  12 | 11, 10 | 9,8,7
    Lightroom:  5.6| 5 | 4 | 3
    Captivate:  8 | 7 | 6 | 5
    Contribute:  CS5 | CS4, CS3
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

  • Record filtered in advance as error records with the same key exist

    Dear Masters
       I am getting below error for master data (0MATERIAL_ATTR), while loading data from PSA to Info object through DTP (I have set the Handle duliocate record also). When I checked that error data in Error Stack, I am getting below error for all records(100)
    "Record filtered in advance as error records with the same key exist"
    Could u please help me to resolve this issue
    Thanks in Advance
    Raja

    Hi
    Thanks for reply
    I have loaded the Delta data in PSA. In PSA data was loaded successfully. I got the failure only when I loaded the from PSA to Maste data
    Thanks in advance
    Raja

  • How to save a variant with dynamic selections parameters

    Anybody knows how to save a variant for an ABAP that uses a Logical database with Dynamic Selections?
    Have a look for example to the following:
    SE38 - DEMO_PROGRAM_GET - Execute - Shift F4 - Connection Number.
    How to save 0820 as Connection Number?
    Function Group SVAR seems good but FREE SELECTIONs are not easy to manage...

    Hello,
      I tried to save the variant of DEMO_PROGRAM_GET with dynamic selection field (Connection Number) filled. It gets saved without any problem. Just click 'SAVE' and enter the variant name and description.
    Thanks,
    Venu

  • How to save a BufferredImage with RGB color encoded JPEG file.

    Hi, I am new to Java Imaging API programming.
    When I try to write a BufferredImage using following code -
    BufferedImage output = new BufferedImage (width, height, BufferedImage.TYPE_INT_ARGB);
    // Save
    File outputFile = new File("image.jpeg");
    ImageIO.write(output, "jpeg", outputFile);
    It seems that myfile.jpg have CMYK color encoding, Can someone tell me how can I save the BufferredImage with RGB color encoding.
    Thanks,
    Sanjay Ujjainkar

    how to format the text ?
    i have format ted the text but it seems not work!
    Message was edited by:
    Enjoyfans

Maybe you are looking for

  • Price Condition Depending of Material Master Record

    Helllo Experts, I have an issue with a price condition on a price procedure  the user wants to be able to mantain the price condition manually only if the material used at item level of sales order is equal to one of 3 sku´s. This Price condition can

  • Coverting PMS Colors to CMYK or RGB

    HI there, I have been given some PSM colors to use for a website but cant find how to convert them to CMYK or RGB. Does anyone know anything about PMS colors and how I would go about converting? 1. Example: PMS 8520 Metallic Light Brown Cheers Mally

  • How to report if i find someone using a stolen phone of other user not mine

    I Saw one user using stolen phone of your apple user and i have number of that number and imei of that robbed mobile... so i can help apple finding that mobile

  • Exporting file to oracle financial analyzer using Excel "Express Add In ?

    i want to export database oracle using "Excel Add-in Express",at present i have to convert the database to PRN/TXT.FILE first before loading it to oracle financial analyzer (via Loading Menu) .Can I use the Excel Express Add In facility to export fil

  • Deployment Errors on JBoss 4.0.4

    I've had the following error since beta2. I've never been able to get it to deploy onto JBoss 4.0.4 and I've posted messages here and the flex coders group with no answers. I'm hoping now that your product is released, I will at least get a response.