java - entitymanager persist -


I have a problem when trying to update the foreign key Using the merge function I always exit the memory error , Or I get timeout

There are many foreign keys (many more lazy fading) in Roum Tables, curious eagerness for Raum Fakultaet and Standort

  @Stateless @Local (IRaumHomeLocal.class) @Remote (IRaumHomeRemote.class) Public Class Raumohom Iryamah Om {@ Presection Private Privilege Manager; Zero Merge (Raum R, Integer Fid, Integer Sid) {Fultat F = em.find (Falcultate, Class, Fid); Standpoint S = em.find (standout class, sid); R.setFakultaet (f); R.setStandort (s); . Adding F.getRaums () (R); . Adding S.getRaums () (R); Em.merge (r); } ....}  

Then I tried to use () instead of searching getReference () because I only want to make an update, so I have the method: < / P>

  zero merge (Raum R, integer fid, integer syd) {standout S = M.A.A.Getreference (standout class, sid); Fultat F = M.A.A.Areference (Falcultate, Class, Feed); . Adding S.getRaums () (R); // Now it is here f.getRaums (). Add (r); Em.merge (r); }  

is still not working
I later removed s.getRaums (). Add (r) and f.getRaums (). Add (r) rows but this is a lazy beginnings exception to me in the next question.

Whatever I need, it's something like this:

  updated RAUm set FakkTaDi = ?, standout ID =? Where RaumID =?  

Am I doing wrong? Is there a better way to do this?

The problem was that I had all the things already in separate state and by doing a search the whole object The tree can be loaded once. The problem was not solved by using em.getReference because the object's special properties are due to its loading, so there was a problem finding it.

The solution is to use only different instances.

The new merge function looks something like this:

  zero merge (Raum R, Fultat F, Standout s) {R.SetSupllet (F); R.setStandort (s); . Adding F.getRaums () (R); . Adding S.getRaums () (R); Em.merge (r); }  

Where all parameters are isolated examples.

This is still a problem (at least for me and my Hibernate version 3.2): Rum after merging different objects) The version of this version has not been updated, so to make a new update An exception would arise, and I had to fix it by increasing the version field in my method.

  Zero merges (Rum R, Fultat F, standout s) {try {r.setFakultaet (f ); R.setStandort (s); . Adding F.getRaums () (R); . Adding S.getRaums () (R); Em.merge (r); R.setVersion (r.getVersion (+ 1); } Hold (runtime expansion) {// throw logging; }}  

It is more than a hack ... but it works and I could not find a better solution that this code is for a website, with different instances Work is the best solution (creating an object tree takes a lot of time and I do not want to make everything with every request)


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -