0

I have below scenario while updating Person entity..

My initial entity:

  • firstName:x
  • preferredFirstName:y
  • name:y (this values is calculated in the database. the logic is if preferredFirstName has value then name = preferredFirstName, else name = firstName)

updated entity:

        person.setFirstName("a");
        person.setPreferredFirstName("b");

now when I do em.merge(person); firstName and preferredFirstName are changed to a and b. But the name field in person entity still holds “y”

I tried:

  1. flush
  2. em.find(person, id)
  3. refresh

None of them seems to be working.

Does any one better way of getting the updated value of the virtual column?

jmvivo
  • 2,653
  • 1
  • 16
  • 20
rohith
  • 733
  • 4
  • 10
  • 24
  • hi @Jmvivo thanks for formatting my question.really appreciate that can you give me some tips on how to format questions ? or point me to a resource? i knew ctrl+k for formatting code. – rohith Dec 17 '15 at 16:57
  • Hi @rohith, just take a look in Help section (http://stackoverflow.com/help/formatting). Regards – jmvivo Dec 18 '15 at 07:38

1 Answers1

0

doing em.flush() followed by em.refresh() did it.

rohith
  • 733
  • 4
  • 10
  • 24