I have started to use JDeveloper 11g and ADF for one of my enterprise level project. I didn't use any part of ADF before. Its now one month and i want to share with world what i found in ADF with JDeveloper 11g.
Pros:
- It is based on MVC pattern and cleanly separates your business logic from presentation layer.
- It has built in support for AJAX
- Very rapid development because most of the development one can do declaratively by just drag and drop components on pages and like that
- Most important and exciting feature from me was very good support of LOV. LOV is required in almost every business application and with ADF i don't have to do any code for LOV just a query and some very small configurations and that's it.
- Rich Tables supporting LOV, combo box and others.
- It provides good hooks to develop own framework or utility classes to suit development e.g. I want to extend all entities from my own class and i can do it very easily.
- One of the unique feature of ADF 11g is ADF Task flow which faciliates developer to define reusable navigation and avoid cluttering of all navigation rules in one file which happens in JSF
Cons
Now we discuss cons of ADF and JDeveloper 11g
- JDeveloper is buggy and crashes many times espeically when one does refactoring or deleting some resources
- You will have to spend good time to learn ADF if you didn't have prior experience with Oracle technologies
- Query component in ADF Faces which is used to build criteria does not have option to change the layout of fields like grouping etc.
- LOV which are generated are also buggy. I am still facing one problem and no one still gave me solution for that.
- You will have to do lot of hit and trials to understand the behaviour of layout components
Showing posts with label cons. Show all posts
Showing posts with label cons. Show all posts
Wednesday, October 28, 2009
Wednesday, July 23, 2008
Inheritance Strategy - Class per hierarchy
Hibernate supports several types of inheritance strategies in which simplest of them is "Class-per-heirarchy". In this strategy, data for all classes involved in inheritance is stored in a single table and a record is identified by discriminator column. Lets discuss this strategy with an example. Suppose there are three classes: Person, Employee, and Physician. Inheritance relationship is shown in the fig below:
Person is an abstract class. So either a person will exist as Employee or Physician. Hibernate mapping for Person is shown below:

Discriminator element creates a column with name "Type", value of which will indicate whether a particular record is Employee or Physician. There is also a special property "abstract" in class element which tells that object of person can't be created.
Hibernate mapping for Employee is shown below:

"subclass" element indicates that there is a class per hierarchy strategy of inheritance between Employee and Person. "extends" property of subclass element creates relationship of "Employee" with "Person". "discriminator-value" tells hibernate to use "Employee" in discriminator column to identify all employees.
Configuration for Physician is given below:

Now lets add two Persons: one is Employee and other is Physician as shown below:
a single table with name "person" will be created in the database with following two records:

Lets retrieve the all person from database and you will observe polymorphic feature of hibernate:
output of the code will be following:
As shown in output, i just retrieved "persons" but it instantiated objects of type to which they belong e.g. Amer Sohail was just an employee not a physician so hibernate created it of "Employee" type. This is really a very powerful feature of hibernate.
Now if i want to retrieve only employee not physician, then i will write the following query:
I explained the strategy "class-per-heirarchy" in this blog's post. This strategy has one major drawback which you should notice while viewing records in table. It contains "nulls" against those records which are not in employee like "speciality" and "billing_address". Since DBMS has to handle null fields with a special case and it creates an impact on performance so that is the major drawback of this strategy because it will create a lot of nulls in the table. but on the other handle, no join is needed so no join cost improves the performance. Now there is very interesting situation bcz pros of this blog says it increase the performance while cons says it decreases the performance so what is the net effect. you have to wait for it for later posts in which i will compare all the strategies.
Person is an abstract class. So either a person will exist as Employee or Physician. Hibernate mapping for Person is shown below:
Discriminator element creates a column with name "Type", value of which will indicate whether a particular record is Employee or Physician. There is also a special property "abstract" in class element which tells that object of person can't be created.
Hibernate mapping for Employee is shown below:

"subclass" element indicates that there is a class per hierarchy strategy of inheritance between Employee and Person. "extends" property of subclass element creates relationship of "Employee" with "Person". "discriminator-value" tells hibernate to use "Employee" in discriminator column to identify all employees.
Configuration for Physician is given below:

Now lets add two Persons: one is Employee and other is Physician as shown below:
Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Employee emp = new Employee(); emp.setName("Amer Sohail"); emp.setPay(123f); session.save(emp); Physician phy = new Physician(); phy.setName("Dr. Amer Sohail"); phy.setPay(345f);
phy.setBillingAddress("Lahore");
phy.setSpeciality("Pediatrics"); session.save(phy); session.getTransaction().commit(); session.close(); a single table with name "person" will be created in the database with following two records:

Lets retrieve the all person from database and you will observe polymorphic feature of hibernate:
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
List emp = session.createQuery("from Person emp").list();
if (emp != null && emp.size() > 0)
{
for (int index = 0; index <>
{
System.out.println("Name of employee is " +((Employee)emp.get(index)).getName());
if (emp.get(index) instanceof Person)
System.out.println("This is person");
if (emp.get(index) instanceof Employee)
System.out.println("This is Employee");
if (emp.get(index) instanceof Physician)
System.out.println("This is Physician");
}
}
session.getTransaction().commit();
session.close();
output of the code will be following:
Name of employee is Amer Sohail
This is person
This is Employee
Name of employee is Dr. Amer Sohail
This is person
This is Employee
This is Physician
As shown in output, i just retrieved "persons" but it instantiated objects of type to which they belong e.g. Amer Sohail was just an employee not a physician so hibernate created it of "Employee" type. This is really a very powerful feature of hibernate.
Now if i want to retrieve only employee not physician, then i will write the following query:
List emp = session.createQuery("from Employee emp where type = Employee").list();
I explained the strategy "class-per-heirarchy" in this blog's post. This strategy has one major drawback which you should notice while viewing records in table. It contains "nulls" against those records which are not in employee like "speciality" and "billing_address". Since DBMS has to handle null fields with a special case and it creates an impact on performance so that is the major drawback of this strategy because it will create a lot of nulls in the table. but on the other handle, no join is needed so no join cost improves the performance. Now there is very interesting situation bcz pros of this blog says it increase the performance while cons says it decreases the performance so what is the net effect. you have to wait for it for later posts in which i will compare all the strategies.
Labels:
class per hierarchy,
cons,
drawbacks,
hibernate,
inheritance,
polymorphism,
pros
Subscribe to:
Posts (Atom)