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")
})

Securing Weblogic with SQLAuthenticator provider

In a previous article we saw how to secure a Web Service with basic authentication (this could be used for every page in our application). We did it creating users with Weblogic Default Authenticator.

Today we will create an SQLAuthenticator in Weblogic, then the server will take users and groups from the data base.

Read the rest of this entry »

JDeveloper Architecture with Weblogic

Seems obvious that the best tool to develop Weblogic/OracleDB is JDeveloper. But for me, until now, it was not so obvious, because Eclipse is my favorite IDE, it is the standard for Java development (Jboss, Spring, Android,…).

If your architecture is Oracle/Weblogic, have no fear to change, and your obsesion is to increase your productivity, then, your tool is JDeveloper. I am gonna write some posts trying to demonstrate this point. But if you want an advancement, you can see this video, you will see howcan be really ssimple make RIA applications over complex enterprise environments.

Read the rest of this entry »

JPA: persistence with EclipseLink

Today we will see how to make the persistence in a Eclipse project with EclipseLink JPA implementation.

We will base in the last post Eclipse project. In the project properties (right buton) we will add the power to manage JPA entities, adding the facet:

Adding JPA facet

We will ue EclipseLink 1.1.2, it is the JPA implementation by defect in WebLogic 11g.

Generating entities from tables

Over the project, in the contextual menu (right button), JPA > Generate Entities from Tables… We choose the conection SCHOOL, created in other posts, and tables REGISTRY and SCHOOLCERTIFICATES. Generating the entities in the package lebrijo.school.model:

Generating entities from tables

To maintain the JPA coherence we must add an Identifier on every classes, Registry has one, but we must add one to SchoolCertificates:

Add Identifier

You may see the file src/META-INF/persistence.xml, how it configures the connection and map the entities.

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="school" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 	<class>lebrijo.school.model.Registry</class>
 
 	<class>lebrijo.school.model.Schoolcertificate</class>
		<properties>
			<property name="eclipselink.target-server" value="WebLogic_10"/>
			<property name="eclipselink.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
			<property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@192.168.0.7:1521:xe"/>
			<property name="eclipselink.jdbc.user" value="school"/>
			<property name="eclipselink.jdbc.password" value="school"/>
			<property name="eclipselink.logging.level" value="FINEST"/>
		</properties>
 </persistence-unit>
</persistence>

here I leaveth eclipse zip project after these steps.

OEPE: Creating a basic Eclipse Project for WebLogic

In the last posts we had defined an Oracle EE architecture, we had installed Oracle XE and we connected it to our Eclipse, and we designed our data model for our example application.

Now we have to create a basic Eclipse project running on Weblogic.

Read the rest of this entry »

Data Model Design with JDeveloper

I consider JDeveloper as a great data base design tool for some reasons:

  • It can navigates through the Oracle databases
  • It has a very good ER editor.
  • It can change the data base schema when you modify the diagram

We can download from Oracle’s web the last JDeveloper version for our operating system. Installing is very easy, you just must have installed the JDK.

Read the rest of this entry »

Oracle XE: Installation and starting with the Data Base

Oracle XE is the 10g version light Data Base implementation for developers and DBAs who wants to make local tests.

It installs downloading the executable file from the Oracle’s web. I had installed the Windows version, virtualizing my Windows XP over VirtualBox (>>) on my Ubuntu.

For administering the Data Base we have a web application at http://192.168.0.7:8080/apex/:

OracleXE administration web application

You can take an idea about the hardware requirements, in my basic installation, the data base fits 605 MB RAM and 880 MB of hard disc. You can see it in the last figure.

Now we will create a data base to host the data of our application. In the web administration application click on Administration > Database Users > Create User, and we create the user school with the same password, checking all the system privileges for it:

Creating DB Schema

Then we have create the school schema, with a user with all the privileges to develop in the data base.

Before access from a remote connection we must activate the option Administration>Manage HTTP Access > Available from local server and remote clients, in the web console.

After that we can connect from any application: Eclipse, JDeveloper, PL/SQL Developer, SQLDeveloper,… In the following screenshot I show how to connect from eclipse even it is our favorite IDE, and with a single screenshot we can see the needed configuration for the connection:

Eclipse DB connection

Eclipse for Oracle

OEPE (Oracle Enterprise Pack for Eclipse), is a Eclipse distro built by and for Oracle products. In order to connect to its Data Bases and to develop with their technologies.

  • It comes with the Data Base Management Perspective, it can recreate all objects (packages, views, synonims,…).
  • Weblogic preloaded, to install by clics. And facilitates the develop of deployment plans over it.
  • JSF libraries (myfaces), and SCA Spring connectors with the apps server.

If you develop Java over Eclipse, with Oracle products backed (DBMS and WebLogic), you must know this Eclipse distro.

Connecting Netbeans to your Data Base

At this post we are going to see how to connect Netbeans IDE to your Database. In my case I work over Oracle SGBD, then I will access to this SGBD.

We will use the JDBC standar, java based for remote DDBB connections purposes.

Read the rest of this entry »

PHPMyAdmin installation

PHPMyAdmin is an administrator of the MySQL data base. Administraton application developed in PHP.

We can publish it in a web server and administer securely our MySQL DBMS remotely, with the only requisite of a web browser.

Read the rest of this entry »

MySQL: Data Base Server installation

We are going to install a MySQL data base server over Debian etch. Read the rest of this entry »