I have three classes of entity(order,customer,sallers) and three classes of Dto. Me need to use Orika for mapping objects from entity classes to Dto. One of this(order) consist of data and links to another Dto objects. How i can map order entity to orderDto with orika uses mapperFactory or different sight mapper in orika. At the moment i have a two mapperFactory for transfer Sellers and Customers to Dto maybe can i use them?
Classes of entity
(hide not important information)
Orders
@Entity
@Table(name="Orders")
@Data
public class Orders {
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "seller_id", nullable = false)
private Sellers seller;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "customer_id", nullable = false)
private Customers customer;
}
Customers
public class Customers {
@OneToMany(fetch = FetchType.LAZY, mappedBy = "order_id")
@JsonIgnoreProperties
private Set<Orders> orders;
}
Sellers
public class Sellers{
@OneToMany(fetch = FetchType.LAZY, mappedBy = "order_id")
private Set<Orders> orders;}
DTO
OrdersDto
public class OrdersDto
{
private SellersDto seller;
private CustomersDto customer;
}