Object relational mapping example

object relational mapping advantages disadvantages and object relational mapping definition
LexiWills Profile Pic
LexiWills,United Kingdom,Professional
Published Date:31-07-2017
Your Website URL(Optional)
Comment
ObjectDBTable of Content ● Introduction to ObjectDB and JPA ● Object Model: Types, Entities, Primary Keys. ● Database Connections ● JPA Fundamentals (CRUD Operations) ● Java Persistence Query Language (JPQL) ● JPA Query API and Criteria Query API ● References 2IntroductionObject Relational Impedance Mismatch Application RDBMS ? ● Database uses tables and records. ● Application uses classes and objects. ● Solutions: ● Application scope (ad hoc) transformations ● Object Relational Mapping (ORM) ● ODBMS (and other NoSQL Databases) 4Object Relational Mapping (ORM) Application RDBMS ORM ● Moderate conservative solution (Adapter) for the Object Relational Mismatch problem. ● JDO, EJB, JPA, Hibernate, EclipseLink, OpenJPA, DataNucleus, Entity Framework, NHibernate. ● Simplifies development (solves many issues). ● Doesn't solve performance issues. 5Object Oriented Databases (ODBMS) Application ODBMS ● No Object Relational Mismatch - application and database share the same class based schema. ● Very effective for complex data models. ● Standards: ODMG (and OQL), JDO. ● Versant, Objectivity/DB, GemStone, ObjectStore, InterSystems Cache, Matisse, db4o, ObjectDB. ● Small market share relative to RDBMS. 6Performance (logarithmic scale) http://jpab.org/All/All/All.html 7Performance (linear scale) http://jpab.org/All/All/All.html 8ODBMS vs RDBMS vs Other NoSQL RDBMS + RDBMS + Most ODBMS SQL (JDBC) ORM (JPA) NoSQL Popularity Very High Very High Low Increasing Tools Many Many Few Few Independent Data Very High Very High Low High Representation Consistency ACID ACID ACID Limited Rich, Fast Query Execution Rich, Fast Rich, Fast Limited (Varies) Complex Models Complex, Slow Slow Fast Varies Object Oriented Low High Very High Varies Integration Scalability High High High Very High 9ObjectDB ● Commercial, free for small databases (up to 10 classes, one million objects). ● History: ● 2003: version 1.0, JDO API. ● 2010: version 2.0, JPA, JDO APIs. ● Current version (2011) – 2.3.2. ● Embedded and Client-Server modes. ● Tools: Explorer, Doctor, Enhancer, Replication, Online Backup, BIRT Driver. 10ObjectDB Sample Users 11ObjectDB Distribution 12API Basics (JPA) import javax.persistence.; Persistence Interfaces EntityTransaction EntityManagerFactory EntityManager Query Exceptions Annotations Enums Entity Embeddable FlushModeType PersistenceException Id GeneratedValues LockModeType TransactionRequiredException 13Object Model (Types)World Object Model Entity Entity public class Country public class City Id String id; Id GeneratedValue Index String name; long id; long population; String name; double area; long population; City capital; boolean capital; ListCity cities; ... SetCountry neighbors; MapString,Float religions; ListString languages; Embeddable GDP gdp; public class GDP Float unemployment; long total; ... int perCapita; ... 15World Database in the Explorer 16Persistent State ● Entity & Embeddable Fields: ● Persistent Fields ● Transient Fields (transient, Transient, final) ● Inverse (Mapped By) Fields ● Entity Fields: ● Primary Key Fields (Id, EmbeddedId) ● Version Field (Version) ● Access Mode: Field / Property 17Supported Types ● User Defined Entity and Embeddable classes ● Java Value Types: ● Primitives (int, float, …) ● Wrappers (Integer, Float, …) ● String, BigInteger, BigDecimal ● Date, Time, Timestamp, Calendar ● Enum types (system and user defined) ● Java Collections and Maps ● Any other serializable type 18Primary Key ● Every entity object can be uniquely identified by type + primary key - e.g. in em.find(cls, pk). ● Primary Key Modes: ● Implicit Primary Key ● Single Field (Id) ● Composite - Multiple Fields (Id, IdClass) ● Composite – Embedded Id (EmbeddedId) ● Most comparable value types are supported. ● Set by Application or by GeneratedValue. 19Composite Primary Key Entity IdClass(ProjectId.class) Class ProjectId public class Project int departmentId; Id int departmentId; long projectId; Id long projectId; ... Entity public class Project Embeddable EmbeddedId ProjectId id; Class ProjectId ... int departmentId; long projectId; 20

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.