vendredi 27 février 2015

In Java EE full container, performance wise, is it better to pass an object around or just let the Entity Manager get it from memory?


Vote count:

0




If I know that a lot of subfunctions are going to use a database object, should I get the object in my main method and then pass it to all the subfunctions to reuse, or is it much of a hit to just get it from the Entity Manager when I actually need it?


I have a multiple layers of iterators, and the object isn't being used until the lowest level. Right now I am getting it on the top level and passing it through 4 layers of methods before actually using it.


The real problem is I would like to use one of the middle functions in another part of the program, and instead of making a needless call to get that object. I would just call the function.


The layout is something like this:



generate()
MyObj obj = getMyObj(); // Entity Manager find

generateSubItems(obj)
generateSubSubItems(obj)
generateSubSubItemValues(obj)
// Use obj


The problem is I want to use generateSubSubItems without having to call getMyObj() if I can because I have to use it quite a few places. I don't really want to be spreading out dependent code all over the place for one, and for two it mucks up the code in the other places which I would like to keep as clean as possible.


Would it be a huge performance hit to do this:



generate()
generateSubItems()
generateSubSubItems()
generateSubSubItemValues()
MyObj obj = getMyObj(); // Entity Manager find

// Use obj


I am using EclipseLink, Glassfish, and SOFT caching.



asked 51 secs ago

abc

352






In Java EE full container, performance wise, is it better to pass an object around or just let the Entity Manager get it from memory?

Aucun commentaire:

Enregistrer un commentaire