[ojb-users] Performance and other stuff
Brought to you by:
thma
From: Jan A. <po...@ag...> - 2002-05-17 08:27:47
|
I'm looking into taking our java programming to the "next level". When implementing our model layer (as in MVC) we typically do something like: class P { public void setValues(ResultSet set) { .. set variables from JDBC set } public void save() { if (isnew) insert() else update(); } public void insert() { .. JDBC insert stuff } public void update() { .. JDBC update stuff } } class locateP { public P getById(id) public Collection getBySomeOther(Other) ... lots of other ways to instantiate P } This is a really simple way to do things 1. its simple and can be auto generated from the database schema - fast development! 2. using jdbcpool to optimize performance is simple 3. SQL :-) but 1. no caching 2. two calls to a method in locateP will return to different instances of the same object - due to no caching X. all the problems that arise because of 2. So will OJB help me out here? mostly web applications!! standalone mode: A: if I have one instance of the Database A1: I will have shared instances of objects because its one database one cache A2: but what about performance? I have a cache, yes, but still all communication with the database is done using -one- connection. Is that a problem? B: One Database object to each Thread or maybe even better one Database per session B2: The performance should be better than A? B1: but no shared instance of object? client/sever mode: C: is that any different than B? Maybe all my troubles are due to my understanding of shared instances of objects - should I say object identity? DB --- server cache --- client A --- client B if client A and B query the same Object instance P (having id = 10) they will end up getting 20 instances due to serialization. How will OJB help me getting A's committed data into B? And if I make a query for instance P having id = 10 and then a query for a collection of P's that all so contains P (id = 10) - will the to instances of P (id=10) be the same object (in memory) meaning that an update to one will be reflected in the other? I know this is a lot to answer but I really need to understand this in order to make a decision to go for OJB (or any other framework). Thanks in advance. Jan Agermose |