You are currently browsing the daily archive for October 8, 2007.

What is Data Access Objects (DAOs)?
1. Abstract CRUD (Create, Retrieve, Update, Delete) operations.
Core J2EE Patterns – Data Access Object

2. Allow different implementations to be “plugged in” with minimal impact to the rest of the system
Advanced DAO programming

DAO in context, where does the business logic go?
1. Domain Objects/Business Objects
* Thin Service Layer and Complex OO Domain Model
* Business logic primarily in the Domain/Business Objects

2. Service Layer
* Thin Domain Layer, Procedural Service Layer
* Fowler’s Anemic Domain Model

Service layer and DAO architecture:
1. Service Layer Contains all Business Logic (no real Domain Model)
This type is a Heavy Service Layer that service Layer directly to Data Access Layer[PEAA: Transaction Script].
#1 Data Access Layer returns Data Transfer Objects (DTOs) to Service Layer.[CJP: Transfer Object]
#2 Data Access Layer returns JDBC RowSets to Service Layer.[PEAA: TableModule/Table Data Gateway]

2. Service Layer contains Use Case Logic that operates over thin or moderately complex domain model
#1 Row Data Gateway simple model tightly coupled to database.(ActiveRecord adds business logic)
#2 Entity Beans BMP/CMP
#3 Data Mapper

3. Complex OO Domain Model/Thin Service Layer
implementation by complex O/R Mapping Framework like TopLink, JDO, Hibernate.

4. Approach:
#1. Fully-Functional Service Layer
Generally matches Use Cases; Provides API to Clients

#2. Data Access
* Simple System – DAO returns DTOs
* More complex System
– Object Model utilizing DataMapper or EJB CMP
– Object Model utilizing JDO or Hibernate

#3. Stateless Session Bean as a RemoteFacade
* Delegates calls to Service Layer
* Returns DTOs to caller

Other issues you may consider:
#1. Unit of Work
Keeps track of “dirty” objects in complicated update scenarios. JDO enhancers and Hibernate classes can do this for us automatically
#2. Identity Map
When loading objects from the database, the DAO should store in a Map keyed by Primary Key so duplicate copies are not loaded
#3. Business Transactions may span multiple database transactions
Optimistic Locking
Pessimistic Locking

Architecture view: 

Spring framework

J2EE architecture


Our user said he open a Crystal Report via web pages and sometimes it showed 404 error page with out of memory exception. I investigated it, and I found other threads worked fine at back-end JBoss. Also when user clicked other pages no problem. I even though debugged the Crystal Report with Servlet back and forth, but I still can’t figure out. Until I found this article:

MSDN: Understanding and Solving Internet Explorer Leak Patterns

So, What is IE Memory Leak?

To begin with let me clarify that memory leaks are not restricted to Internet Explorer but it can happen in any browser. We are talking primarily about IE as over the course of my time, I have found it to cause this issue more often than any other browser. Memory leak is a condition where your web application keeps consuming more and more memory as you keep navigating or refreshing. This causes decrease in responsiveness of the application and in situations can crash the browser itself.

How to Detect Internet Explorer Memory Leaks

IE Memory Leaks

Memory Leakage in Internet Explorer – revisited

IE’s Memory Leak Fix Greatly Exaggerated

Memory leak patterns in JavaScript

Wiki: Memory Leak