A DBA Perspective on J2EE Debu Panda Principal Product Manager Oracle Corporation Session id: 40019.

Slides:



Advertisements
Similar presentations
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
Advertisements

11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
EJB Entity Beans. Entity Beans Data versus logic Used to represent an instance rather than a collection of data (depending on underlying storage) Represents.
An architecture for webb applications, J2EE
6/1/20151 Luca Simone Software Engineering 2 a.a. 2001/2002.
1 Softsmith Open Learning - EJB 21-Nov Enterprise Java Beans Introduction –Application ServerApplication Server –Java 2 Enterprise EditionJava.
Integrating SOA and the Application Development Framework Shaun O’Brien Principal Product Manager – Oracle JDeveloper / ADF.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
1 James Lynn Hewlett-Packard Middleware Division EJB Architecture Design Strategies and Performance Optimizations.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
Enterprise Applications & Java/J2EE Technologies Dr. Douglas C. Schmidt Professor of EECS.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
Point Of Sale(POS) J2EE Application Department : Computer Science Degree : Master Student : Woojin Choi ID : (POS J2EE Application with JRun)
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
A DBA Perspective to J2EE Debu Panda Principal Product Manager Oracle Application Server Development
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Enterprise Object Framework. What is EOF? Enterprise Objects Framework is a set of tools and resources that help you create applications that work with.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
1 INTRO TO BUSINESS COMPONENTS FOR JAVA (BC4J) Matt Fierst Computer Resource Team OracleWorld Session
EJB Overview Celsina Bignoli Distributed Business Applications Server DB Client DB Server DB.
Enterprise Java Beans CS-422. Application Servers In the late 1980s and though the mid 1990s a number of corporations (Broadvision, Netscape…) marketed.
Enterprise Java Beans - (EJB)
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
Entity Beans BMP Celsina Bignoli
Middleware Technology (J2EE/EJB) Entity Bean. 2 Introduction to Entity Beans Persistence Concepts Entity beans are persistent objects that can be stored.
© D. Wong  Indexes  JDBC  JDBC in J2EE (Java 2 Enterprise Edition)
Entity Java Beans Jorg Janke Open Source ERP & CRM.
Container-Managed Persistence (CMP) Entity Beans Lesson 3A / Slide 1 of 42J2EE Server Components Objectives In this lesson, you will learn to: Identify.
Distributed Systems 1 Master of Information System Management Distributed Systems Persistence.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Enterprise JavaBeans. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports application development.
Message-Driven Beans and EJB Security Lesson 4B / Slide 1 of 37 J2EE Server Components Objectives In this lesson, you will learn about: Identify features.
J2EE Structure & Definitions Catie Welsh CSE 432
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
Collaborate Lesson 4C / Slide 1 of 22 Collaborate Knowledge Byte In this section, you will learn about: The EJB timer service Message linking in EJB 2.1.
Creating competitive advantage Copyright © 2003 Enterprise Java Beans Presenter: Wickramanayake HMKSK Version:0.1 Last Updated:
Understanding Impact of J2EE On Relational Databases Donald Smith, Technology Director Dennis Leung, VP Engineering Oracle Corporation 40038:
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
EJB Overview: Constraint Types and Enforcement in JBoss Elissa Newman Fluid Meeting 6/3/04.
Entity Beans & Persistence Chris Alexander CS 486 Spring 2001.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Copyright © 2002 ProsoftTraining. All rights reserved. Enterprise JavaBeans.
13 Copyright © 2004, Oracle. All rights reserved. Managing Persistent Data in the Business Tier Entity EJBs.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications.
Building J2EE Applications Based on Design Patterns with Business Components for Java Olivier LE DIOURIS Principal Product Manager Oracle Corporation.
J2EE Platform Overview (Application Architecture)
Entity Bean Chuyên đề Lập trình Java & J2EE Chương 15
Running a Forms Developer Application
Introduction to J2EE Architecture
Understanding and Designing with EJB
Luca Simone Software Engineering 2 a.a. 2001/2002
Objectives In this lesson, you will learn to:
Understanding and Designing with EJB
Entity Beans B.Ramamurthy 2/17/2019 BR.
Knowledge Byte In this section, you will learn about:
Component-based Applications
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 4/5/2019 B.Ramamurthy.
Enterprise Java Beans.
Knowledge Byte In this section, you will learn about:
Presentation transcript:

A DBA Perspective on J2EE Debu Panda Principal Product Manager Oracle Corporation Session id: 40019

Impedance Mismatch I love my tables DBA I love my objects and beans Java Developer

Overview  J2EE Overview  EJB Overview  Entity Bean Lifecycle for the DBAs  Persistence Options and related concerns  Optimizing CMP Entity beans for Oracle database  Other DBA Considerations  Additional Resources and Next Steps  Complete Your Survey ( Session Id#40019)

Mind boggling J2EE J2EE JSP JDBC EJB JNDI JTA JMS Servlet JCA

What is J2EE?  Java 2 Enterprise Edition (J2EE) – Platform to build scalable and portable applications in Java – Relies on a number of Java specifications  Servlets, JSPs, EJB, JMS, JDBC, JTA, JNDI, etc.  DBAs care most about JDBC,JTA and EJB  JDBC – Java APIs for Database access  JTA – Java APIs to manage transactions  EJB – Enterprise JavaBeans  Oracle Application Server Containers for J2EE (OC4J) is J2EE 1.3 compliant

Develop J2EE Applications with Oracle Application Server Database OHS Browser JSP Servlets JTA JMS JNDI Java Mail JAAS Java VM Oracle Application Server JDBC J2EE Container JCA EJBs (Session, Entity, MDBs) EJB Client EJB Client CORBA Client CORBA Client RMI http RMI-over-IIOP

What is EJB  Reusable components that run inside a container  Can be accessed either – Either local and remote Java programs – CORBA compliant client  EJB Container provides support for – Persistence – Access control – Transactions

Enterprise JavaBean Review EJB client OC4J Enterprise Services Naming, Transactions, Security Database EJB container EJB bean EJB remote object EJB home object EJB remote interface EJB home interface JMS Listener MDB bean JMS client

Types of EJBs  Session Beans – encapsulate business logic – Transient in nature, cannot survive crash ! – Stateless – Perform a task e.g. charge a credit – Stateful – Maintains state between calls e.g. shopping cart  Entity Beans – persistent in nature – Representation of data – Two types Bean Managed Persistence (BMP), Container Managed Persistence (JMS)  Message Driven beans – A Java Message Service (JMS) listener (listens on a Topic or Queue) – Reliably consume message – Can work with Oracle Advanced Queueing

Entity Beans Uncovered  Represent persistent objects  Have a Primary key for unique identification  BMP requires developers to code all persistence – Use JDBC to perform persistence  CMP requires container to do the persistence based on declarations – Container does database access based on declarations by developer

Container Managed Relationships  Only between CMP EJBs  Supports 1-1, 1-M, and M-M  Relationships can be unidirectional or bi-directional  Relationships are persistent just like EJBs  Can have DELETE-CASCADE property Customer id: int name: String creditRating: int Address id: int city: String zip: String *

Entity Bean Life Cycle Client EJB Container EJB Server create() Entity bean remove() ejbUnsetEntityContext() ejbRemove () ejbLoad() ejbStore() EJB object stub Bean constructor ejbCreate(…) primary key constructor ejbSetEntityContext() ejbPostCreate()

Entity Bean Lifecycle and database MethodOperationDB Operation ejbCreate()Create an entity bean instance INSERT to persist the bean instance ejbPostCreate()Set relationshipUPDATE foreign key or INSERT if deferred write ejbLoad()Load a bean instance using the supplied primary key SELECT statement to retrieve a database row ejbStore()Update the corresponding bean in the database UPDATE to a database row ejbRemove()Remove a bean instanceDELETE the record findByXXX()Find the beans based on a certain condition SELECT statement to fetch one or multiple rows

EJB Creation  Happens in 2 steps – ejbCreate  Basic insert statement – ejbPostCreate  Relationships made here  Deferred constraints important because of this 2 step process – Only way to deal with mandatory foreign keys

EJB Removal  Simple delete from database  Can support cascade-delete – Only on 1 side of 1-1 or 1-M relationships – Declared by tag when EJB is deployed X

Finding EJBs  EJB-QL is the EJBs language for queries  Similar to SQL-92 / SQL-99  Container creates findByPrimaryKey  Can create other finders – findAll selects whole table – Other finders limited only by EJB-QL – OC4J allows SQL more flexible than EJB-QL select distinct object(e) from Emp e where e.deptno = ?1

Loading EJB State  EJB is loaded when it is needed for operation – Happens after it is found with findBy method  Container handles loading EJB persistent state  Container loads all persistent attributes  Can do pessimistic or optimistic locking

Saving EJB State  Saving state occurs at end of transaction  By default, container optimizes when possible – Saves only changed attributes – Will not write out if no state changed  Developer can intervene with ejbStore method

The Classic N+1 Problem  The N + 1 problem – Mostly with BMPs, with some CMP engines – Beans located via finder methods – Bean finders return PK values N reads: select * from emp where empno = empPK; 1 read: select empno from emp where deptno = 100;  Container creates bean instances to return – Calls ejbLoad for each PK returned

J2EE Persistence Options  J2EE standards based options are – Direct JDBC from web-tier or EJB session beans – Entity beans with Bean Managed Persistence – Entity beans with Container Managed Persistence  Additional technologies (Related Sessions !!) – Java-to-relational frameworks such as Oracle Application Server TopLink – Oracle ADF (Application Development Framework)

Direct Access with JDBC  Developer codes all interactions with database – Queries, inserts, updates, deletes using JDBC API  Common design pattern used – Data Access Objects – Separates persistence from business logic – Avoids putting JDBC code directly in Servlet/JSPs  Nil to low overhead from container – Developer is responsible for opening/closing resources – Transactions managed programmatically  Concurrency considerations  DBA Concerns: Review SQL

Bean Managed Persistence  Using BMP – All database interactions are manually coded – Container calls your code when it performs an operation – Container still ultimately in control  Provides some implementation flexibility – Map to 1 or more tables, different storage systems – Make use of existing stored procedures  Performance perceptions and reality – Developer coded *may* be better than container generated – Inherent problem with (n + 1) SQL calls  DBA Concerns: Database schema is coded into bean, Review SQL

Container Managed Persistence  Using CMP – Developer specifies persistent attributes of object – Developer specifies how entity object maps to database – All JDBC code generated by container  Container is responsible for managing persistence  Container maintains relationships between objects  Requires less code than JDBC and BMP  Choice for persistence in J2EE Applications  DBA Concerns : Many !! If you are not using Oracle Application Server

CMP development and deployment Concerns  Container Managed Tables – Containers creates the tables and names those – Ask your developers to map to your schema  Container creates Primary key – If no primary key is assigned in Entity bean – OC4J names this column autoid by default  Container Managed Relationship – May create an extra table for maintaining relationship – You can use foreign key for mapping 1-M

Performance Concerns  Container generates the SQL – SQL statement that can cause performance degradation by making full table scans or unnecessary joins – Unnecessary Extra SQL statements  Developers specify finder methods that can make full table scans  How to tune database for use with CMPs

Optimizing CMP Entity beans for Oracle database  Reduce database operations  Use right concurrency mode and locking strategy  Tune your SQL/database

Reduce Database Operations  Enforce primary key constraint at database level – Avoid extra SQL for constraint checking by container  Exploit DELETE CASCADE at database level – Container generate multiple SQL statements  Defer EJB creation to end of transaction – This avoids an extra UPDATE statement  Batch update operations to end of transaction  Exploit eager loading of relationship  Reduce round trips with pre-fetch size  Avoid N+1 problem by switching off lazy-loading

Use Right Locking/Isolation Mode  Choose the right isolation level for entity beans – Avoid if possible at the bean level – COMMITTED performs better than Serializable  Choose right locking mode – Use Optimistic and Read-Only if possible – Pessimistic uses ‘SELECT FOR UPDATE’  Avoid database calls with Read-Only patterns

Database Tuning Tips for CMPs  Make sure that your finder /select method uses indexes.  Exploit statement caching by the container  Avoid findAll() on large tables as this makes full table scans  Most EJB systems are OLTP in nature so tuning redo is important  The basics of tuning any database are valid for EJBs  Use Statspack to find bottlenecks and tune your DB

OC4J Tools and Instrumentation  Dynamic Monitoring System (DMS) – Instrumentation of application and server – Oracle Application Server Performance Guide  Platform dependant document  P6Spy – Plug in JDBC driver to capture SQL – Good development tool –  Statspack

OracleAS Toplink – A Compelling Option  Improves developer productivity by providing a flexible O-R Framework – Avoiding manual coding of interactions with database – Have years of experience in Java to RDB mapping  Can be used in any J2EE application – Servlets/JSPs / EJBs (BMP/CMP)  Reduces the load on database – Resolving the N+1 problem – By using caching data in the middle-tier and reading ‘Just In Time’ – Minimizing database calls  Utilize the features provided by databases  Respect and work with database locks

Other DBA Concerns  Database user passwords – Used in data-sources for connection pooling – Stored in clear text, can be encrypted ! – Changes require restart of container  OC4J uses an Oracle database for commit coordinator for 2-Phase commit – Requires a 9i database as commit coordinator – Requires database links ?

JMS and Oracle AQ  OC4J uses two JMS providers – OC4J JMS – Internal/in-memory JMS – OracleJMS – based in Oracle AQ  JMS uses – Queues – single consumer – Topics – multiple consumers  OracleJMS persists messages in AQ tables – As DBAs you have to manage these objects

Summary  J2EE is a popular platform  Persistence is the greatest challenge for developers and may impact DBA’s life  DBAs and Developers work together to improve the quality of J2EE applications

Reminder – please complete the OracleWorld session survey Session Id : Thank you.

Next Steps..  Related Sessions – # Improving performance of Your J2EE Applications : Tips and Moscone Room 202, Tuesday 8:30am – #40038 – Understanding the Impacts of J2EE Applications on Relational Moscone 135, Wednesday 1:00pm  Visit Oracle Application Server Booths in Demo Grounds  Attend OC4J Hands On Lab

otn.oracle.com Join Over 3,000,000 Developers! Free Software Downloads Free Technical Advice

 Develop your career with Oracle’s experts – Web services, Forms Upgrade to the Web, TopLink, Business Intelligence, Integration, J2EE, Linux  Connect with your peers  Sign up at FREE

A Q & Q U E S T I O N S A N S W E R S