Persistence

Post on 16-Nov-2014

280 views 1 download

Tags:

description

Java Persistence

Transcript of Persistence

Ennovation – Behind the Products

Anish Alex, CTO

• Closest native language support– Serialization

• Lifecycle– Begins and Ends with JVM

• Identity– Equals / Hashcode / Memory Location

• Data Types– Int/long/string..

• RDBMS– Long term persistence / Primary Key – SQL– VARCHAR / NUMBER

2 Evolvus Solutions. Proprietary and Confidential, do not copy, duplicate or distribute.

Java Persistence Problem

• Object Relational Mappers – ORM’s– Map Java objects to Relational database

table records e.g.– Top Link / Hibernate

• Java Data Objects (JDO)– Apache jdo

• JDBC• Java Persistence API (JPA)

– Hibernate– Top Link– Open JPA

• EJB• Custom

3 Evolvus Solutions. Proprietary and Confidential, do not copy, duplicate or distribute.

Java Persistence Technologies

Java Persistence Technologies

Evolvus Solutions. Proprietary and Confidential, do not copy, duplicate or distribute.4

HibernateRelational Persistence for Java

• XML file to map POJO to Tables• Configuration• Classes to bootstrap the framework• JPA Implementation

6 Evolvus Solutions. Proprietary and Confidential, do not copy, duplicate or distribute.

Hibernate - Relational Persistence for Java

Sample CodeORM

• Generators– native– increment– sequence– assigned– hilo / identify / uuid.hex / uuid.string / foreign

• Version– Prevents invalid overwrites

• Property– String – specify length– BigDecimal – specify precision/scale– Date / Timestamp / Long - nothing to specify

8 Evolvus Solutions. Proprietary and Confidential, do not copy, duplicate or distribute.

Hibernate ORM

• References– http://www.mkyong.com/tutorials/hibernate-

tutorials/– http://docs.jboss.org/hibernate/orm/3.3/

reference/en/html/index.htmlPrevents invalid overwrites

– Sample code - http://codeserver/demo-repository/svndemo/anisht/trunk/training/hibernate

9 Evolvus Solutions. Proprietary and Confidential, do not copy, duplicate or distribute.

Hibernate ORM

• To-Do– One-to-Many using foreign keys– Many-to-One– Many-to-One using foreign keys– One-to-One– Run the same examples against SQL Server

10 Evolvus Solutions. Proprietary and Confidential, do not copy, duplicate or distribute.

Hibernate ORM

THANK YOU !!

Questions / Contact