Database (entity obejct) <-> DTO (transfer object) <-> EJB cloud <-> UI that uses DTO.
This is probably a common way to implement an application that takes advantage of Javas EJB but it also means A LOT of set and get between the DTO and the database entitys when you need to transfer data from backend to frontend.
Our first solution was a simple one, we used reflections to find getters and setter and then just transferred the values. However problem arised when we had lists with complex types i.e. DTO's in DTO's. Our copy properties class util just grow bigger and the performance was terrible!
One day we found this lovely tool on sourceforge called Dozer, Dozer homepage. Out of the box it handles all of these problems without any problem and it perform great! I made a quick benchmark with 10000 entitys and found it 8.6 times faster than our own implentation :)
It works like this. Lets say we have our entity object DogEO and our transfer object DogDTO:
DogDTO dto = new DogDTO();
dto.setHeight = 2;
dto.setWeigth = 23;
DogEO dogEo = new DogEO();
MapperIF mapper = new DozerBeanMapper();
dogEo = (DogEO) mapper.map(dto, DogEO.class);
This maybe seems like a small problem but trust me when you have 30+ DTO's with complex structure and content that are subject to constant change, then this is the shit!