Identity Map Pattern
This pattern belongs to Object-Relational Behavioral Patterns Catalog and this Catalog belongs to Patterns of Enterprise Application Architecture . Intent Ensures that each object gets loaded only once by keeping every loaded object in a map. Looks up objects using the map when referring to them. An Identity Map keeps a record of all objects that have been read from the database in a single business transaction. Whenever you want an object, you check the Identity Map first to see if you already have it. How It Works The basic idea behind the Identity Map is to have a series of maps containing objects that have been pulled from the database. In a simple case, with an isomorphic schema, you�ll have one Map per database table. When you load an object from the database, you first check the map. If there�s an object in it that corresponds to the one you�re loading, you return it. If not, you go to the database, putting the objects on the map for future reference as you load them. Choic