jpa persist , merge ?

Discussion in 'Java' started by john, Dec 24, 2010.

  1. john

    john Guest

    I have entity A and it has FK to entity B.(B is some lookup table)

    when I do this

    A a = new A();
    B b = new B();
    b.setId(1L);
    a.setB(b);

    and then i call em.persist(a) jpa generates first SQL select statement
    to get entity B, and then it generates SQL insert, but when I call
    em.merge(b), there is only SQL insert statement ? Why does persist()
    needs to check if FK that is set to A exists, and merge() doesn't ?


    THANKS IN ADVANCE.
    john, Dec 24, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. redbull
    Replies:
    2
    Views:
    734
    Kenneth P. Turvey
    Oct 31, 2007
  2. Lew
    Replies:
    3
    Views:
    1,854
  3. Lew
    Replies:
    0
    Views:
    642
  4. kamiseq
    Replies:
    1
    Views:
    1,096
    Tom Anderson
    Dec 29, 2009
  5. kamiseq
    Replies:
    6
    Views:
    2,213
    Arved Sandstrom
    Dec 31, 2009
Loading...

Share This Page