I have a question regarding how to use an object oriented approach while using an RDBMS such as mysql. I am developing a small application that will keep track of billing. It is built in java and I am using a MySQL database to store data. My application has a costumer and a product class. Now normally if I were dealing with persistent data storage using arrays or different data containers I would have an update, delete etc for the customer class and one for the product class. However I find my self using more static methods than ever before. Because I don't have a array of customer for example I just have a database with customers info I see no point in creating a customer object just to delete it when I could just call a static method that deletes a customer (or product) based on it's primary id. In the end I feel like there is no reason to even create a customer or product class because there is no need for specific methods.
What I would like to ask everyone is how do you take an object oriented approach when using a RDBMS?
Design your Java classes using OO principles.
Design your DB with SQL and normalisation principles.
Then, run full speed into the challenge that is Object/Relational Mapping! :-)
Technologies like Hibernate and Ibatis are designed specifically to help with this, it's a well documented problem. Additional technologies like Spring can make their use really quite easy and pleasant to work with.
Abstract your persistence to a DAO (Data Access Object) layer, e.g. if you've got lots of classes like Vehicle and Animal, you would have DAOs like VehicleDao and AnimalDao to separate out how they talk to the DB from what they fundamentally do in your system.
FWIW, I advocate doing just this: good app design on the app side, good DB design on the data side. With that done, there's always a way to map the two when persisting and retrieving class data to and from the DB, and that's far better IMO than compromising one of your individual layers to "help" the other.