The very first aspect is mapping. Hibernate requires the POJO (Java objects that represents the tables) be mapped with the tables using XML. That means if there is even a slight change in the Database schema such as the length of a particular field is changed, then you will have to make changes not only to the corresponding POJO but also to the mapping file. If you fail to do so, then run-time exception is the most common and the least problem that you will face.
Now lets look at Active Record. The driving principle of Rails is “Convention-over-Configuration” (but version 2.0 is deviating from it, more on that later). So , to map a class to a database table you just have to follow conventions. The conventions are
- The class derives from ActiveRecord::Base i.e. Base class of ActiveRecord module
- The name of the class must be same as that of the table
- The name of the class should start with a capital letter (though this applies to all Ruby classes)
Authors Note: I am really sorry for the gap between the posts. It wont happen again (this time for sure). For now on you can expect atleast one post in a week.
