P
P
Pavel Talaiko2020-01-18 18:02:29
Java
Pavel Talaiko, 2020-01-18 18:02:29

How to merge two different entities on unrelated fields in Criteria Hibernate?

Hello.
How to merge two different entities on unrelated fields in Criteria Hibernate?
The question is.
You need to make the following request.

SELECT COUNT(P.ID) FROM TBX_P_PRODUCT P 
INNER JOIN TBX_CH_CHARACTERISTIC CHS ON CHS.ID_PRODUCT_ROW = P.ID 
AND (CHS.VALUE IN ('value'))

@Entity
@Table(name = "tbx_p_product")
class Product  {
    private id: UUID = null
    private var title: String? = null
}


@Entity
@Table(name = "tbx_ch_characteristic")
class Characteristic {

    private id: UUID = null
    private var title: String? = null
    private var idProduct: UUID? = null

}

Entities are not specifically related via OneToMany and ManyToOne(idProduct and Id)
Need help how to write this via entityManager criteria.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question