Showing posts with label Ibatis. Show all posts
Showing posts with label Ibatis. Show all posts

Saturday, 21 June 2014

Object Relational Mapping - ORM

Object Relational Mapping (ORM)


        ORM is a technique for conversion of data between in-compatible type systems in object - oriented languages.Databases do not use the concept of Object Oriented languages wherein we associate objects to demonstrate the state of the systems. Database map values to primitive datatypes such as integer, real , float , String etc .Consider an example -         You have to insert an employee details into the database.If we use contemporary technique you need to convert that employee details to primitive value i.e. formulate an insert/update query with these details for that employee and then insert/update to the database.

This problem is solved by ORM .

          The Object Relational Mapping transforms any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings let you map an object model into a relational data model.

         Relational mappings transform object data members to relational database fields. Use them to map simple data types including primitives (such as int), JDK classes (such as String), and large object (LOB) values. You can also use them to transform object data members that reference other domain objects by way of association where data source representations require object identity maintenance (such as sequencing and back references) and possess various types of multiplicity and navigability. The appropriate mapping class is chosen primarily by the cardinality of the relationship.

Some ORM supporting APIs 

Java - 


 .Net 



Thursday, 19 June 2014

Hibernate Vs IBatis

Hibernate Vs Ibatis

There are major differences between iBatis and Hibernate but both the solutions work well, given their specific domain. Personally I would suggest you should use iBATIS if:
  • You want to create your own SQL's and are willing to maintain them.
  • Your environment is driven by relational data model.
  • You have to work on  existing and complex schema's.
  • Your environment is driven by object model and wants generates SQL automatically.
  • iBATIS is:
  • Hibernate:

And simply use Hibernate if:
You can differentiate between two as  - 
    • Simpler
    • Faster development time
    • Flexible
    • Much smaller in package size
    • Generates SQL for you which means you don't spend time on SQL
    • Provides much more advance cache
    • Highly scalable
Other difference is that iBATIS makes use of SQL which could be database dependent where as Hibernate makes use of HQL which is relatively independent of databases and it is easier to change db in Hibernate.
Hibernate maps your Java POJO objects to the Database tables where as iBatis maps the ResultSet from JDBC API to your POJO Objets.
If you are using stored procedures, well you can do it in Hibernate but it is little difficult in comparision of iBATIS. As an alternative solution iBATIS maps results sets to objects, so no need to care about table structures. This works very well for stored procedures, works very well for reporting applications, etc
Finally, Hibernate and iBATIS both are open source Object Relational Mapping(ORM) tools available in the industry. Use of each of these tools depends on the context you are using them. Hibernate and iBatis both also have good support from SPRING framework so it should not be a problem to chose one of them.