Look up java.lang.reflect .
Given an object o , you can get its class c and its methods m . your dto will have the same method signatures.
then create an instance of your dto class d. if there is a relation between your entity name and dto name, then from then entity name you should be able to get the dto name.
loop through the method array
for each getter method in your bean you can call the corresponding setter method in your dto.
Thanks! I will investigate.