Tag Archives: Java

Design: ADF Templates and skins

Usually, in all our web projects, we want all the pages have a coherent style in ehole site, to improve the usuability. The usual strategy is fix the header (with the login for example), a menu in the top or both sides, and a footer.

  • And all this parts are included in all our pages with no repeat the code.
  • Every change in the template will show in whole site.
  • And, if is possible, our WYSIWYG editor shows me the design (it is not possible with Eclipse for the moment).

Continue reading Design: ADF Templates and skins

JPA: modelo de persistencia

En este artículo crearemos un modelo de persistencia para nuestra pequeña aplicación de gestión de empleados. Basado en un anterior post donde creamos una aplicación básica de JDeveloper.

Sobre el proyecto en el menú contextual, New > EJB > Entities From Tables. Vamos a utilizar la tecnología EJB 3.0, anotando los beans de entidad como JPA 2.0:

Creating persistence model

Seleccionamos las tablas Departaments y Employees.

Como vimos en un artículo anterior, se puede obtener el diagrama de una base de datos ya hecha. Yo me lo he creado en el paquete lebrijo.diagrams:

Entity-RelationShip diagram

Podemos crear un New > EJB Diagram, y arrastrando las entidades anteriormente creada, tendremos el dibujo entero:

EJB diagram

En los dos beans refactorizaré el atributo employees por manager, ya que define más claramente la relación.

Refactoring manage relation

Esto se actualiza automáticamente en el diagrama de EJB (en teoria, en realidad hay que volver a arrastrar las entidades).

Como último ejercicio, podemos crear la consulta de encontrar por nombre, ampliando la anotación de consultas de la entidad Employees:

@Entity
@NamedQueries({
@NamedQuery(name = "Employees.findAll", query = "select o from Employees o")
,
@NamedQuery(name = "Employees.findByName", query = "select o from Employees o where o.firstName like :p_name")
})

JPA: persistence model

In this post we will create a persistence model for our little employee management application. Based on an earlier post where we created a basic JDeveloper Web application.

Over the project with contextual menu, New > EJB > Entities From Tables. We will use the EJB 3.0 technology, annotating entity beans as JPA 2.0:

Creating persistence model

Select Departaments and Employees tables.

As seen in an earlier post, we can obtain the ER diagram from a made data base. I created it in the package lebrijo.diagrams:

Entity-RelationShip diagram

We can create a New > EJB Diagram, and drag-drop the created entities, we have the whole draw:

EJB diagram

I refactored the employees attribute by manager, because it defines the relationship better.

Refactoring manage relation

This is refreshed automatically to the EJB diagram (theory, in practice I have to drag the entities again).

As last exercise, we can create the ‘find by name’ query, in the query annotation at Employees entity:

@Entity
@NamedQueries({
@NamedQuery(name = "Employees.findAll", query = "select o from Employees o")
,
@NamedQuery(name = "Employees.findByName", query = "select o from Employees o where o.firstName like :p_name")
})