fix reference to param
add builders that define entity and relation objects
use Entity class in writeEntity