In my project we use the combination of Spring data + Hibernate annotations.
http://projects.spring.io/spring-data-jpa/
Here an example:
@Repository
public interface InformCandidacyRepository extends CrudRepository<InformCandidacy, Integer> {
List<EvaluationCandidacy> findByCandidacyPublicProcurementId(Integer publicProcurementId);
InformCandidacy findByCandidacyId(Integer id);
}
And the hibernate mapping done by annotations
@OneToOne
@JoinColumn(name = "candidacy_id", nullable = false, insertable = false, updatable = false)
@Getter
@Setter
private Candidacy candidacy;
@OneToOne(orphanRemoval = true, optional = true, cascade = {CascadeType.ALL}, mappedBy = "candidacy")
@XmlElement
@Getter
@Setter
private InformCandidacy informCandidacy;