From: pmz on 3 Aug 2010 09:30 On 3 Sie, 15:08, Lew <no...(a)lewscanon.com> wrote: > Trim your posts. Don't quote sigs. Pardon me. > > You ignored Arved's advice that this 'merge()' is unnecessary, I see. Apparently I've tried not using the 'merge()', but no effect found! > > > ut.commit(); > > > The row has been updated (in the database), with such log message: > > ... > > > Unfortunately, I have some problems with data preview - in the browse > > page I have the old data (e-mail value is i.e. old_value) but when I > > Apparently you didn't refresh the view. You mean, I should blame the webbrowser cache? P.
From: Arved Sandstrom on 3 Aug 2010 17:07 pmz wrote: > On 3 Sie, 15:08, Lew <no...(a)lewscanon.com> wrote: >> Trim your posts. Don't quote sigs. > > Pardon me. > >> You ignored Arved's advice that this 'merge()' is unnecessary, I see. > > Apparently I've tried not using the 'merge()', but no effect found! [ SNIP ] Don't get the idea that I'm saying that merge() is useless; just be aware of specifically what it's for. It's for bringing detached entities back into a persistence context; inside a transaction (and in this case you've got a JTA transaction using the UserTransaction API) a find() or query will return managed entities and so merge() is not required. Also, if you use merge(), bear in mind that you must then use the managed copy which is returned. You're not in the wrong here (except for using merge in the first place); just keep this in mind. It's not a bad habit to get into to always assign the return value from merge(). If you're doing this in a servlet bear in mind that entity managers are not thread-safe, so I'd inject with @PersistenceUnit instead, to get an EntityManagerFactory. Then create your EM from the EMF after you start the user transaction. AHS -- Give a man a fish, and he can eat for a day. But teach a man how to fish, and he'll be dead of mercury poisoning inside of three years. --Charles Haas
From: pmz on 4 Aug 2010 07:51 On 3 Sie, 23:07, Arved Sandstrom <dces...(a)hotmail.com> wrote: .... > > If you're doing this in a servlet bear in mind that entity managers are > not thread-safe, so I'd inject with @PersistenceUnit instead, to get an > EntityManagerFactory. Then create your EM from the EMF after you start > the user transaction. > > AHS > Thank you very much! I'll try to work your way, which I believe is the good one ;) All the best, Przemek M. Zawada
First
|
Prev
|
Pages: 1 2 Prev: Windows On Screen Keyboard problem with serial port? Next: Reg exp question |