170 likes | 279 Views
Tallinna Tehnikaülikool Informaatikainstituut Javal baseeruv objektide püsivuse kiht Jakamar Bakalaureusetöö Üliõpilane: Erki Suurjaak Matrikli nr: 970772 Juhendaja: Tarmo Veskioja. Defence Overview. What is object persistence What solution did I propose What is Jakamar
E N D
Tallinna Tehnikaülikool Informaatikainstituut Javal baseeruv objektide püsivuse kiht Jakamar Bakalaureusetöö Üliõpilane: Erki Suurjaak Matrikli nr: 970772 Juhendaja: Tarmo Veskioja
Defence Overview • What is object persistence • What solution did I propose • What is Jakamar • Benefits and tradeoffs
Objects Objects Objects What is object persistence • objects existing beyond application’s lifetime Application Data Store
Concerns using OOP and RDBMS • handling changes in the data structure • possible to reuse persistence logic
What solution did I propose Persistence Broker design pattern • enables full separation of business and persistence logic • easily customizable for different applications • offers useful functionality, like object caching
User Interface Classes Business classes Persistence Broker Cache Database User Interface Classes Business classes Database Architecture Simple architecture Using a Persistence Broker
What is Jakamar • a reusable component • provides automated persistence
architecture program flow functionality error handling security concurrent use logging configuration Jakamar in the thesis
Benefits • Easier maintenance • Less program code to write: access to persistence via simple operations like • store(object) • delete(object) • retrieve(query criteria)
Benefits (2) Accessing the database directly Using Jakamar Connection connection = DriverManager.getConnection("jdbc:odbc:emt"); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM PERSON WHERE location = 'Jõhvi'"); Collection results = newArrayList(); while (rs.next()) { Person person = newPerson(); person.id = rs.getInt("id"); person.firstName = rs.getString("firstName"); person.lastName = rs.getString("lastName"); person.location = rs.getString("location"); results.add(person); Statement stmtSub = connection.createStatement(); ResultSet rsSub = stmtSub.executeQuery( "SELECT * FROM PHONE WHERE personId = " + person.id); while (rsSub.next()) { Phone phone = new Phone(); phone.id = rsSub.getInt("id"); phone.personId = rsSub.getInt("personId"); phone.phone = rsSub.getString("phone"); person.phones.add(phone); } stmtSub.close(); } stmt.close(); connection.close(); PersistenceBroker broker = PersistenceBrokerFactory.create("conf.xml"); Person param = newPerson(); param.location = "Jõhvi"; Query query = broker.createQuery(param, new String[]{"location"}, null); Collection results = broker.retrieveCollection(query);
Tradeoffs • decrease in functionality • with embedded SQL,extremely complex queries accessible as easily as simple retrieval • with Jakamar, restrictions on query complexity
Benchmarks • better performance on object retrieval • worse performance on storing objects Repeated? - whether the same operation was repeated multiple times
Conclusion • the Persistence Broker pattern is a good approach • Jakamar is a viable component • faster development • better modularized application structure • possibly better performance on retrieval
Further development • cursors • transactions • Object Query Language • distributed use • extent classes • graphical configuration interface
Persistence Broker Caches persistent objects Looking up cached instances Retrieving Storing and deleting Accesses object fields dynamically Deleting storage and deletion Persistence Mapping Delegating queries from the application to lower level Reflection Contains mappings between classes and tables Specifying the field values of objects to store or delete Returning the field values for retrieved objects Converts object field values to table column values and vice versa Specifying the criteria field values Query Mechanism Conversion Handles executing SQL statements Cache Database-specific SQL queries Application Application Applications Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Identities Persistent Objects Queries Queries Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Column Values Field Values Field Values ACTION Queries SELECT Queries SELECT Results Field Values Field Values Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Field Values Persistent Objects Persistent Objects Persistent Objects Persistent Objects Persistent Objects Database