@utluiz, got a grade 10! I had to do the following, I created a view in my DB:
select c.id_customer, c.tenant_id, c.first_name, ds.name
from viatgedb.customer c
join viatgedb.customer_service cs
on c.id_customer = cs.fk_customer
join viatgedb.destination_requested ds on cs.id_customer_service = ds.fk_customer_service;
Soon after I did the JPA mapping (I'm working with the multi-tenant architecture):
@ReadOnly
@Entity
@Table(name="vw_open_services")
@Multitenant
@TenantDiscriminatorColumn(name = "tenant_id", discriminatorType = DiscriminatorType.INTEGER, contextProperty = PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT)
public class VwOpenService implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="id_customer")
private Long id;
@Column(name="tenant_id", insertable=false, updatable=false)
private Long tenantId;
@Column(name="day_service")
private String dayService;
@Column(name="first_name")
private String firstName;
@Column(name="NAME")
private String name;
// Getter and Setter
And I've usually created a repository to bring my records with Spring Data:
@Repository
public interface OpenServiceRepository extends BaseRepository<VwOpenService, Long>{
List<VwOpenService> findAll();
}
The result was as expected.
Thank you