Sunday 12 July 2015

OCEJWCD-10.More options for the Model

OCEJWCD (SCWCD) - 1Z0-899 - Web Component Developer Certification

10.1. Understand the roles of JDBC and JPA

JDBC is Java DataBase connectivity, the traditional mechanism to access relational database from Java. 
-There are 4 categories of JDBC drivers.
-Provides an implementation of independent generic database access methods.
-Optimizing network resources using connection pooling and distributed transactions.

From JavaEE 5 JPA (Java Persistence Application) low level details are hidden when implementing persistence layer. 
There are several implementations of JPA : Hibernate(JBoss), OpenJPA. The standard implementation for Oracle is Toplink.

Persistence mechanism:
  • POJO objects
  • Metadata mapping : XML has connection details and table mappings. Also there is an option of using annotations.
  • EntityManager connect metadata and database (request, synchronizing data).

10.2. Understand the many elements that make up the model

Handling remote objects:
  • JNDI - Java Naming Directory Interface. Locate remote objects.
  • RMI - Remote Method Invocation. Process to communicate objects across the network (low level network IO operations).

10.3. Understand fundamentals of connecting to a database using JDBC or JPA

The optimal solution is to use a connections pool, every time a request is received, it uses a connection from the pool. The pool is managed by the JavaEE server.

The configuration about pool connections is declared in deployment descriptor.
Assigning name in JNDI (java name directory interface), allows locate service by name.

Configuring datasource in deployment descriptor (web.xml) example:
<resource-ref>
  <res-ref-name>jdbc/New</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
  <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

Configuring datasource with annotations, example:
@Resource(name = "jdbc/New")
http://docs.oracle.com/javaee/6/api/javax/annotation/Resource.html

Annotations can be defined in a class, method or a field.
Other annotations:
@EJB
@PersistenceContext : to specify the container managed entity manager.

OCEJWCD (SCWCD) - 1Z0-899 - Web Component Developer Certification

No comments:

Post a Comment