mercredi 4 novembre 2015

where map dto to entity bean

1. Design aproach
There're an entity,dto,service and facade beans. Quite typical I guess

    MyRequest {
      ...
      List<MyData> myData;
    }
    MyRequestDto {
      List<Long> myDataIds;
    }
    MyService {
      MyRequest findRequest()
    }
    MyFacade {
     MyRequestDto findRequest() 
    }

That was easy. According to the theory facade should delegate calls and convert entity->dto
But what about save operation ? Where to map dto to entity as it's more complex operation.
MyService should have method like:
- save(MyRequest) // maybe too much responsibility for facade
- save(MyRequestDto) // mix layers, maybe facade is not needed then
- save(Long id,...,List) myDataIds) // can be too many arguments

2. how to deal with lists in jpa? Replace

myRequest.setMyData(fetchMyData(myDataIds))

or should I manually synchronized the list.
I suppose it should depends on volume of the data

Aucun commentaire:

Enregistrer un commentaire