1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common_test_tester.support;
17
18 import java.util.List;
19
20 import javax.persistence.EntityManager;
21 import javax.persistence.PersistenceContext;
22 import javax.persistence.Query;
23
24 @Deprecated
25 public class MyDaoImpl implements MyDao {
26
27 private EntityManager entityManager;
28
29 @PersistenceContext
30 public void setEntityManager(EntityManager entityManager) {
31 this.entityManager = entityManager;
32 }
33
34 public String createValue(Value value) {
35 entityManager.persist(value);
36 return value.getId();
37 }
38
39 public String findValue(String id) {
40 Value tv = entityManager.find(Value.class, id);
41 if(tv==null){
42 return null;
43 }
44 return tv.getValue();
45 }
46
47 @SuppressWarnings("unchecked")
48 public Value findValueFromValue(String value) {
49 Query q = entityManager.createQuery("SELECT v FROM Value v WHERE v.value=:valueIn");
50 q.setParameter("valueIn", value);
51 for(Value tv : (List<Value>)q.getResultList()){
52 return tv;
53 }
54 return null;
55 }
56
57 public boolean updateValue(String id, String value) {
58 Value v = entityManager.find(Value.class, id);
59 v.setValue(value);
60 entityManager.merge(v);
61 return true;
62 }
63
64 }