llefevre wrote:
Do you mean you are working outside of a session? I don't understand if you are working inside a transaction and your comment is just here to tell that or if you commented the transaction "begin" and "commit" instructions.
working inside the the session but committing data after each run. the log entry contains what was processed for a single run so transaction is committed after each run to ensure data integrity. before this implementation, everything was running inside the same transaction and that brought hibernate to its knees (large object graph inside a session was causing horrendous performance). I was really hoping someone would have known what the problem is with the Hibernate's Set but so you better understand what this process does....
a) query - get about 1,000 entities
b) clear the session
c) start the transaction
d) load the first entity
e) process it (this process performs large number of add/update/delete)
f) add element to the log (log contains links to information that was processed so that it can be reported, undone...)
g) commit the transaction
h) clear the session
and then from c) to h) again until all 1,000 are processed...
llefevre wrote:
If you are working inside the transaction then try starting it outside thee loop and committing after the loop.
already tried, hibernate performs extremely slow when there is a large object graph inside the session so we had to re-design to this. The process (that takes couple of minutes using JDBC only implementation) was taking 4+ hours with this implementation
llefevre wrote:
If not, it seems you are working in a session detached mode and I advise you to implement the equals() and hashCode() methods of the objects being added to a Set.
Not working in session detached mode. And just to point out that the problem definitely is not in equals() and hashCode() as the same operation on normal implementation of Set takes no time whatsoever. So to better explain
Code:
public class OverdueLog {
private Set<OverdueLogEntry> logEntries; // this is mapped in hibernate
private Set<OverdueLogEntry> testLogEntries; // this is just a plain 'ol Set
... // getters and setters
public void addLogEntry(OverdueLogEntry entry) {
getLogEntries().add(entry);
}
public void addTestLogEntry(OverdueLogEntry entry) {
getTestLogEntries().add(entry);
}
}
public class SomeOtherClass {
public void process(...) {
... some processing code
overdueLog.addLogEntry(entry); // this takes forever
overdueLog.addTestLogEntry(entry); // takes 0ms
}
}
[/code]