source: src/main/java/com/example/medweb/repository/impl/TerminRepositoryImpl.java

Last change on this file was e5fefbd, checked in by Anita Terziska <63020646+Nit4e@…>, 2 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1package com.example.medweb.repository.impl;
2
3import com.example.medweb.model.Termin;
4import com.example.medweb.repository.TerminRepositoryCustom;
5import org.springframework.context.annotation.Primary;
6import org.springframework.stereotype.Component;
7
8import javax.persistence.EntityManager;
9import javax.persistence.PersistenceContext;
10import java.util.List;
11
12
13@Primary
14@Component("custom")
15public class TerminRepositoryImpl implements TerminRepositoryCustom {
16
17 @PersistenceContext
18 private EntityManager entityManager;
19
20 @Override
21 public List<Termin> findAllByTerminId(Integer termin_id) {
22 return entityManager.createQuery("select o from Termin o where o.termin_id = :termin_id",
23 Termin.class).setParameter("termin_id", termin_id).getResultList();
24 }
25
26 @Override
27 public Termin findByTerminId(Integer termin_id) {
28 return entityManager.createQuery("select o from Termin o where o.termin_id = :termin_id",
29 Termin.class).setParameter("termin_id", termin_id).setMaxResults(1).getSingleResult();
30 }
31
32 @Override
33 public void deleteByTerminId(Integer termin_id) {
34 entityManager.createQuery("delete from Termin o where o.termin_id = :termin_id");
35 }
36}
Note: See TracBrowser for help on using the repository browser.