java - Spring @Transactional merge and persist question -


New for Spring and here @ StackWarflow

I have a stand-alone inventory & amp; Distributor Business Sales Tracking App (Apache Pvot / Spring / JPA / Hibernate / MySQL)

So far, I think everything is CRUD, so I want to plan a base class with everything @translegal.

Then there is a problem to save me from my normal way. Is there any difference in merge and merge method from EntityManager to Spring?

I tried to walk and both were saved to add and update and it worked fine (I think every time I call, the spring is automatically healthy method // Sleeping questions are being seen to save, is it correct?).

  @ Transaction related public abstract class generic DOA {protected EntityManager em; // em holder + @stensecontact / setter public sound save (tt) {// if (TGID (== faucet) // new // // em.persist (t) Create; //} else // update // {em.merge (t); //}}}  

And with BTW, having such a setup, I will not have much compromise in the right performance? To prepare the report (which does not require transaction, right?), Call calling cells DDA.FundL () is like calling.

Thank you!

There is a good discussion of continuous versus mergers, and it conveys very well in the accepted answer. Other answers also link to a good blog post about it.

According to the first answer, it seems that it would be possible to merge to save and update an entity, but it is not how I 've done it in my Spring / JPA apps, I have been expanding JPADo support to my DAO and getJpaTemplate () used in the following manner.

  / ** * Save a new album * / Public Album Save (album album) {getJpaTemplate (). Continue (album); Return album; } / ** * Update an existing album * / Public Album Update (album album) {return getJpaTemplate (). Merge (album); }  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -