Hibernate - Criteria Inner Join

Build an Inner Join in Hibernate:

Solution:

@Entity
@Table(name = "shop_product_uid")
public class ShopProductUid {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "shop_product_id")
private ShopProduct shopProduct;
@Column(name = "shop_product_uid")
private String shopProductUid;
@ManyToOne
@JoinColumn(name = "shop_product_uid_type_id")
private ShopProductUidType shopProductUidType;

Criteria criteria = session.createCriteria(ShopProductUid.class)
criteria.createAlias("shopProductUidType", "shopProductUidType") // inner join by default
.add(Restrictions.eq("shopProductUidType.typeId", parameterTypeId));

Comments

Popular posts from this blog

Oracle - duplicate fields in RECORD,TABLE or argument list are not permitted

Oracle - ORA-29282: invalid file ID, ORA-06512: at "SYS.UTL_FILE"