|
|
I have a fully functioning batch application that I am attempting to performance tune.
I have a large (40,000) number of Users that have Training History information that could potentially need updating (we schedule their training based upon business needs).
I have attached my applicationContext, a class demonstrating the problem (SpeedTest.java), and the stack trace of the problem that I am trying to solve WITHOUT creating a massive transaction for a job that could potentially take 30 minutes.
If I change the SpeedTest class by adding @Transactional to the runTest method, it functions properly, though in the massive transaction.Code: public static void main(String[] args) { String file = quot;applicationContext.xmlquot;; ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(file); SpeedTest st = (SpeedTest) ctx.getBean(quot;stquot;); st.runTest(); }
@Transactional public void runTest() { .... }
I want to still have smaller transactions within the code, (possibly in batches of 10 users, or even a transaction per user depending on performance), but I really need to share the same Hibernate Session through the entire job. I have lazy relationships that all refer to the same set of domain objects (Module) but the class with the relationship has too many records (over 6 million) to load at once. I already have code to evict the instances of the large table once I'm done with them from the session. It's the common classes that they have a many to one relationship with that needs to remain in the session.
I currently use the HibernateTemplate in my DAO class, and I've even gone so far as to attempt to rip that out since it's no longer recommended, but it changes my application to a non-functional one. Remember, everything is working, it's just that I am doubtful that a 30 minute transaction would be safe to run, and I can't take the performance hit of having to re-query and re-hydrate the many-to-one relationship for the hundreds of domain objects per user.
I've attempted to change the behavior with the HibernateInterceptor, but I've read that it conflicts with the HibernateTransactionManager that I'm already using through the annotations.
I want to be able to control when a session gets bound to the thread and is made available through SessionFactory.getOpenSession(). I don't care if it is through a Proxy, AOP, Explicit Java code in my methods or what, I just want control over the life cycle of that Hibernate Session.
Please help, I've googled, searched through the forum, and even found some threads that were close, but couldn't get me to where I want to be:
showthread.php?t=59250
showthread.php?t=26892
showthread.php?t=43298
Thank you in advance.
Jeremy D. Young |
|