Hello,
I'm working on a small research. I want to know if it is possible to find patterns of Hibernate usage in source code, that (can) affect the Hibernate performance (in a bad way), by static code analysis. If it is then, I want to know what these patterns are and how I can find them with static code analysis.
I'm planning to develop an open source tool that find some of these patterns, and warns/advises the developer. This tool can be very useful for developers that use Hibernate but are not really experienced.
Right now I'm searching for some patterns but that seemed harder than I thought. Some of the patterns I found are:
1 A query executed in a loop.
2 When you have an extraordinarily large number of columns (say: >50) in a table and the setting dynamic-update and dynamic-insert are not set true.
3 Accessor methods of collection properties in a persistence class that don’t return or set the actual property (because, collections are compared by identity. In that case you avoid unnecessary updates). To clarify: you want to avoid, for example, the following code in a persistence class:
Code:
public void setNames(List namesList) {
names = (String[]) namesList.toArray();
}
public List getNames() {
return Arrays.asList(names);
}
I hope that some of you can help me with finding some more patterns. Or give me some references where I can find some more patterns.
Thank you all very much in advance =)!
--Jasper