IS-907 Java EE JPA: Simple Object-Relational Mapping.

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
Data Management and File Organization
Representing Data Elements Gayatri Gopalakrishnan.
Entities and Persistence. Entity Beans Topics to be Covered: Entities are POJOs Managed/Unmanaged Entities Persistence Unit EntityManager Basic Relational.
Designing a Database Unleashing the Power of Relational Database Design.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
The Java Persistence API Edel Sherratt. Contents Revisit applications programming Using Java Persistence API.
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Towards Bboogle 3.0.0: a Technical Walkthrough Patricia Goldweic Sr. Software Engineer AR&T, Northwestern University Brian Nielsen Manager, Faculty Support.
Training - Day 3 OJB. What is OR Mapping? OR Mapping is the mapping of relational database tables to objects (Java Objects in our case) Many OR Mapping.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
1 Lecture 17 George Koutsogiannakis/SUMMER 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
Avro Apache Course: Distributed class Student ID: AM Name: Azzaya Galbazar
Attribute Data in GIS Data in GIS are stored as features AND tabular info Tabular information can be associated with features OR Tabular data may NOT be.
JPA Java Persistence API. Introduction The Java Persistence API provides an object/relational mapping facility for managing relational data in Java applications.
Object Oriented Design: Identifying Objects
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Introduction to Entities
BPJ444: Business Programming using Java Java basics Tim McKenna
Dali JPA Tools. About Dali Dali JPA Tools is an Eclipse Web Tools Platform sub-Project Dali 1.0 is a part of WTP 2.0 Europa coordinated release Goal -
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
OVERVIEW ON HOW ENTITY FRAMEWORK CODE FIRST CAN EASE THE DEVELOPMENT PROCESS Entity Framework Code First 11/19/2013 Joe Walling Copyright Walling Info.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Chapter 9 Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design.
1 Part 2: EJB Persistency Jianguo Lu. 2 Object Persistency A persistent object is one that can automatically store and retrieve itself in permanent storage.
Topic : JPA Kaster Nurmukan. Overview of JPA EntityManager.
OK lets start, who am I ?. Nayden Gochev (a.k.a. JOKe) Java Spring Android Hybris GWT EJB JSF RMI JAX-RS Struts JMS JPA Hibernate C# ASP.NET TestStudio.
Review of ICS 102. Lecture Objectives To review the major topics covered in ICS 102 course Refresh the memory and get ready for the new adventure of ICS.
1 JDBC Aum Amriteshwaryai Namah. 2 2 JDBC – Java DataBase Connectivity.
1 Mapping Persistent Objects Entities represent data in the database, so changes to an entity bean result in changes to the database. That's ultimately.
1 Architectural Overview For application developers, assembling enterprise beans requires little or no expertise in the complex system-level issues that.
1 Persistence in Java Enterprise Container Managed Persistence Application Managed Persistence Michael Brockway Sajjad Shami CG0165: Advanced Applications.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Topic : Hibernate 3:Advanced ORM Kaster Nurmukan.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
The Java Persistence API ©SoftMoore ConsultingSlide 1.
v110912Java Persistence: EntityManager2 Overview Earlier versions of EJB Specification defined the persistence layer –javax.ejb.EntityBean Java EE 5 moved.
Java Persistence API (JPA) Relationships. Kinds of relationships UML associations and aggregations (ER non- identifying relationships, shared semantics)
Howard Paul. Sequential Access Index Files and Data File Random Access.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
IS-907 Java EE Introduction to JPA. Java Persistence API A framework for using relational databases in Java programs mapping between tables and classes,
Hibernate Thuy, Le Huu. Pentalog VN. Agenda Hibernate Annotations Improving performance – Lazy loading – Fetching Strategies – Dynamic insert, dynamic.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
CS422 Principles of Database Systems Object-Relational Mapping (ORM) Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Object-Relational Mapping with Hibernate and JPA Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Object-Relational Mapping with Hibernate and JPA (I) Chengyu Sun California State University, Los Angeles.
Hibernate Java Persistence API. What is Persistence Persistence: The continued or prolonged existence of something. Most Applications Achieve Persistence.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Java Programming Language Lecture27- An Introduction.
Object-Relational Mapping. Contents  Default Mapping Rules  Elementary Mapping  Embeddables  Relationship Mapping  Inheritance Mapping.
Chengyu Sun California State University, Los Angeles
An Introduction to Java – Part I
Unit-2 Objects and Classes
An Introduction to Java – Part I, language basics
JDBC – Java Database Connectivity
JPA: Mapping to an existing database
Java Programming Course
Applying OO Concepts Using Java
Programs and Classes A program is made up from classes
Java Programming Review 1
Topics Persistence API for JAVA EE5 Java Transaction API Entity class.
Chengyu Sun California State University, Los Angeles
Introduction to java Part I By Shenglan Zhang.
Presentation transcript:

IS-907 Java EE JPA: Simple Object-Relational Mapping

Object-Relational-Mapping Description of how an object model “maps” to a relational data model Class to table(s) Object properties (attributes) to columns or relations The mapping can be described as java source code annotations, or in xml mapping files xml mapping files override the source code annotations IS Course Info2

JPA Entity annotations To mark a class as a persistent entity (i.e. that objects of the class can be stored in a database), use annotation: import public class Employee {... } JPA will attempt to use the classname as a table name, and the attribute names as column names IS Course Info3

Persistence Unit and entities All classes annotated are included in the PU Additional classes may be included: Classes with entries in xml mapping files Classes listed in elements in persistence.xml You can use persistence.xml to exclude classes: use an element use elements to include the entities you want No other classes will be included! Even Åby Larsen IS-102 Introduksjon4

JPA Id annotations annotations is used to specify the primary key. annotation can be used to specify automatic generation of the primary key values import public class private long empNo;... } IS Course Info5

@Id, primary key, and object identity The primary key defines the identity of an entity The equals method defines the identity of an object They should yield the same public class private long empNo; public boolean equals(Object o) {... return this.empNo == that.empNo; } Even Åby Larsen IS-102 Introduksjon6

Mapping simple types Fields of the following types are mapped automatically to a column with the same name as the field: byte, int, short, long, boolean, char, float, double Byte, Integer, Short, Long, Boolean, Character, Float, Double byte[], Byte[], char[], Character[] java.math.BigInteger, java.math.BigDecimal String java.util.Date, java.util.Calendar java.sql.Date, java.sql.Time. java.sql.Timestamp enum types Serializable classes Even Åby Larsen IS-102 Introduksjon7

Field access mode Mapping annotations can be put on the field itself, or on the get methods If the fields are annotated, JPA will access the fields directly (bypassing the private restriction) to get or set their value If the get methods are annotated, JPA will use the get and set methods all persistent fields must have getters and setters Even Åby Larsen IS-102 Introduksjon8