Features of ORM

Download Report

Transcript Features of ORM

Object Relational
Mapping
What is ORM
Defining structural relationships between object-oriented and relational
representations of data, typically to enable the use of a relational
database to provide persistence for objects
Why we use ORM
Features of ORM
Basic features
Be able to use inheritance, create hierarchies between entities, and
use polymorphism (we are using objects!). The tools can support a
variety of combinations for tables and classes to allow these
mechanisms.
Handle any type of relations (1-1, 1-n, n-n)
Support for transactions
Aggregates (equivalent to SQL's SUM, AVG, MIN, MAX, COUNT)
Support for grouping (SQL's GROUP BY)
Features of ORM
Flexibility
Support any type of SQL joins (inner join, outer join)
Concurrency management (support for optimistic and pessimistic
approaches)
Support for the data types specific to the database management
system (identity columns, sequences, GUIDs, autoincrements)
Features of ORM
Be able to map a single object to data coming from multiple
tables (joins, views). Most of the tools handle a direct mapping of a
class to one table. We often need more.
Be able to dispatch the data from a single table to multiple objects.
Features of ORM
Advantages of ORM
Huge reduction in code. ORM tools provide a host of services
thereby allowing developers to focus on the business logic of the
application rather than repetitive CRUD (Create Read Update
Delete) logic. .
 Changes to the object model are made in one place. One you
update your object definitions, the ORM will automatically use the
updated structure for retrievals and updates. There are no SQL
Update, Delete and Insert statements strewn throughout different
layers of the application that need modification.

Advantages of ORM
Data loads are completely configurable allowing you to load the
data appropriate for each scenario. For example in one scenario
you might want to load a list of POs without any of it's child /
related objects, while in other scenarios you can specify to load a
PO, with all it's child Line Items, etc.

Advantages of ORM
Concurrency support. Support for multiple users updating the
same data simultaneously.
 Cache management. Entities are cached in memory thereby
reducing load on the database.
Transaction management and Isolation. All object changes occur
scoped to a transaction. The entire transaction can either be
committed or rolled back. Multiple transactions can be active in
memory in the same time, and each transactions changes are
isolated form on another.


Advantages of ORM
Key Management. Identifiers and surrogate keys are
automatically propagated and managed.
 Transparency
Using object-relational mapping instead of JDBC or ODBC can
reduce your development time and improve your performance.


Disadvantage of ORM
When a class changes, one will be not only be required to
change its corresponding table but also the corresponding tables
of its child classes.
2. When a bulk of data is deleted, object SQL mapping tools do not
perform well.
1.