You are currently browsing the monthly archive for November 2008.

Sometimes we need to test our web service but you just simply test. How? You don’t need to create a client call, request your front-end Servlet, or complex test. Basic you get “SOAP message”, then you send it over HTTP POST to web service URL. Using “cURL”, “Apache TCPMon” or “soapUI”, those tools can help you.

For example, I use “cURL” to test and return me correct SOAP-response.

curl –request POST -H “Content-Type: text/xml” -H “SOAPAction:” –data @ZIPcode_soap_req.xml

Look at those useful tips.

1. Mocking Web services

2. Debugging Web Services

3. Using TCP Monitor to Debug Web Service Calls

4. soapUI eclipse-plugin

Sometimes I forgot the EJB3 specifications and I need to find it right now. So I always has link for them.

1. Hibernate Annotations and API

2. Hibernate EntityManager and API

3. TopLink JPA Annotation Reference

4. Package javax.persistence API

After having done the EJB3 implementation, then we walk into the performacne issue.
I google it to get “Hibernate/EJB3 Tuning“. Also I suggest you to look at book of “Manning EJB3 in action” to find out tuning your EJB3 project.

Here I posted some from book.

13.2 Improving entity performance
–13.2.1 Remodeling and schema redesign
—-Merging tables
—-Dividing a table into multiple tables
—-Choosing the right inheritance strategy
–13.2.2 Tuning the JDBC layer
—-Properly sizing the connection pool
—-Caching SQL statements
—-Using named queries
—-Avoiding transactions for read-only queries
–13.2.3 Reducing database operations
—-Choosing the right fetch type
—-Deferring database updates until the end of transactions
—-Using the lowest-cost lock in the database
—-Using DELETE_CASCADE appropriately
—-Using the cascade property
—-Bulk updates
—-Avoiding association tables in one-to-many relationships
–13.2.4 Improving query performance
—-Avoiding full-table scans
—-Using indexes to make queries faster
—-Filtering based on a nonidentity field
—-Using indexes for relationship fields
—-Ordering a collection of entities
—-Using functions in the WHERE clause of JPQL
—-Reducing round-trips to the database
–13.2.5 Caching
—-Using an extended persistence context
—-Persistence unit level cache
—-Read-only entities

When you decide to implement JAX-WS from Java EE 5.0, then you have many choice to do XML binding. You can handle it as Capstor, XMLBean, or JAXB2. Here is some resources.

1. Exchanging Data with XML and JAXB, Part 1-2

2. Generate an XML Document from an Object Model with JAXB 2

3. Ant: Launching xjc

4. Java EE 5 tutorial: Binding between XML Schema and Java Classes

I had worked at legacy code to migrate from Spring POJO into EJB3. I try to do ORM with Composite Design Pattern. Here is my solution. Suppose I want to have employee and their direct manager at report. So I create a Composite Design pattern that has abstract class EmplyeeComponent, Employee and Manager.

(Reference: A look at the Composite design pattern)

For EJB3 entity bean: use Many-To-One self referencing relationship.

abstract class EmployeeComponent implements Serializable {
private String name;

public String getName();




public class Employee extends EmployComponet{



protected Long employeeId;




Manager manager;




public class Manager extends EmployComponet{



protected Long managerId;


Table design:

Database hierarchy query:

select a.Employee_ID employeeId, b.Employee_ID managerId
from employee a, employee b
where a.MANAGER_ID = b.Employee_ID