jeudi 17 septembre 2015

Java-ee 7 (EAR, EJB, WAR) project design pattern

My question is not about a specific problem. It is more about design. I hope it is ok to ask this kind of a question. Now, I want to build an application in Netbeans. Application will perform basic CRUD operations on Students and Courses. Here are my settings in NetBeans:

  • Create a Java EE application.
  • Java EE 7
  • Glassfish 4.1
  • Create EJB Module: projectname-ejb
  • Create Web Application Module: projectname-war
  • I will use JPA & JPQL

By the way, "projectname-ejb" and "projectname-war" are mandatory. Now what I want to know is that what is the best structure for this case. Some say it's good to use DAO while other say it's not. Some say avoid to call entities in "WAR" project. I realy want to know what is the best structure for a "Java EE 7" project with JPA.

What I have in my mind is:

In EBJ project

package: com.company.entities
- Student.java
- Course.java

package: com.company.dao
- interface StudentDao.java
- interface CourseDao.java

package: com.company.dao.impl
- StudentDaoImpl.java
- CourseDaoImpl.java

In WEB-App

package: com.company.managedbean
- StudentMb
- CourseMb

Should I create a Student entity in "StudentMb" in order to work with the StudentDao instance or should I create another package with domain(pojo) classes and in EJB layer convert them into entities before do crud operations on database?

Long story short: What is a good structure to work with this kind or any other kind of Java EE (EAR) projects in 2015?

Aucun commentaire:

Enregistrer un commentaire