Intent

Database programming with Technology:JDBC

Description

This is a sophistication of Contribution:jdbc. We experiment with a naive O/R mapping for companies. We exercise some company scenarios with the resulting object model. In the implementation of the O/R mapping, we use JDBC.

Architecture

The package org.softlang.company contains the object model. The ObjectFactory in org.softlang.util is used to retrieve objects from the database. The PersistenceTool writes objects back to the database. Some minimal effort is made to only commit *changes* to the database. The tests package org.softlang.tests contains test cases.

Prerequisites (very much like in project "jdbc"):

Usage

  • You will need a suitable JDBC Driver for MySQL
  • Set up a company database.
    • Follow the steps described here Contribution:mySqlMany to set up the company database. That is, stop after populating the tables.
  • There are JUnit tests available as the package org.softlang.tests.
    • Run class Basics with JUnit to exercise basic features.
    • Run class Persistence with JUnit to exercise O/R mapping / persistence.

Issues

  • Overall, the idea of loading employees one by one may be ill-conceived.
  • Lazy load is triggered upon testing collection items for changes; see Department.isChanged.
  • The load method should not be in the iterator for collections but in the getters (and some of the setters) for items in the collection.
  • Persist methods seem to drill down to leafs even beyond what had been loaded (and could be changed).
  • Clear methods should use information about what has been *added* or *removed*.
  • The id after insertion should be determined in a more robust manner.
Cosmetics:
  • Rename ObjectFactory to Loader?
  • Rename PersistenceTool to Saver?
  • Use shorter names pstmt -> stm for example.
  • Use overloading rather than long names such as persistDepartment.


There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.