Posts

Showing posts with the label criteria

Criteria API query fails

Image
Clash Royale CLAN TAG #URR8PPP Criteria API query fails I'm new at Criteria and can not understand the next thing. I've got entities with сonnection between each others User: //...fields... @OneToOne(fetch = FetchType.LAZY, mappedBy = "user") private Document document; Document: //...fields... @OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn private User user; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "doc_type_id", nullable = false) private DocType docType; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "citizenship_id", nullable = false) private Country country; DocType: //...fields... @Column(nullable = false, length = 5) private String code; Country: //...fields... @Column(nullable = false, length = 5) private String code; I need to find user with a document that contains the docCode (DocType.code) and citizenshipCode (Country.code). Dao: //private final EntityManager em; public List<User> filterUser(U...

Using sum in hibernate criteria

Image
Clash Royale CLAN TAG #URR8PPP Using sum in hibernate criteria How can I express this query in hibernate criteria?? select SUM (tabla2.valor1) from tabla1 INNER JOIN tabla2 ON tabla1.ID = tabla2.ID where tabla1.ID = 1 Thanks! By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.