Skip to content

Commit 412f52c

Browse files
committed
fixing code to pass test
1 parent e09342d commit 412f52c

5 files changed

Lines changed: 15 additions & 11 deletions

File tree

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.devnexus.ting.core.dao;
22

33
import com.devnexus.ting.core.model.registration.EventSignup;
4+
import org.springframework.stereotype.Repository;
45

5-
public interface EventSignupDao {
6+
public interface EventSignupDao extends GenericDao<EventSignup, Long>{
67

7-
EventSignup getByEventKey(Long eventId);
8+
EventSignup getByEventKey(String eventKey);
89

910

1011
}

src/main/java/com/devnexus/ting/core/dao/jpa/EventSignupDaoJpa.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@
1717

1818
import com.devnexus.ting.core.dao.EventSignupDao;
1919
import com.devnexus.ting.core.model.registration.EventSignup;
20+
import org.springframework.stereotype.Repository;
2021

22+
@Repository("eventSignupDao")
2123
public class EventSignupDaoJpa extends GenericDaoJpa< EventSignup, Long>
2224
implements EventSignupDao {
2325

24-
public EventSignupDaoJpa(Class<EventSignup> persistentClass) {
26+
public EventSignupDaoJpa() {
2527
super(EventSignup.class);
2628
}
2729

2830
@Override
29-
public EventSignup getByEventKey(Long eventId) {
31+
public EventSignup getByEventKey(String eventKey) {
3032
return super.entityManager.createQuery("select es from EventSignup es "
3133
+ " join es.event e "
32-
+ "where e.id = :eventKey", EventSignup.class)
33-
.setParameter("eventKey", eventId)
34+
+ "where e.eventKey = :eventKey", EventSignup.class)
35+
.setParameter("eventKey", eventKey)
3436
.getSingleResult();
3537
}
3638

src/main/java/com/devnexus/ting/core/model/registration/EventSignup.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.HashSet;
66
import java.util.Set;
77
import javax.persistence.Cacheable;
8+
import javax.persistence.CascadeType;
89
import javax.persistence.Entity;
910
import javax.persistence.ManyToMany;
1011
import javax.persistence.ManyToOne;
@@ -23,7 +24,7 @@
2324
@XmlAccessorType(XmlAccessType.FIELD)
2425
public class EventSignup extends BaseModelObject {
2526

26-
@ManyToMany
27+
@ManyToMany(cascade = CascadeType.ALL)
2728
private Set<PurchaseGroup> groups = new HashSet<>();
2829

2930
@ManyToOne

src/main/java/com/devnexus/ting/core/model/registration/PurchaseGroup.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.HashSet;
66
import java.util.Set;
77
import javax.persistence.Cacheable;
8+
import javax.persistence.CascadeType;
89
import javax.persistence.Entity;
910
import javax.persistence.ManyToMany;
1011
import javax.persistence.ManyToOne;
@@ -16,6 +17,7 @@
1617
import javax.xml.bind.annotation.XmlTransient;
1718
import org.hibernate.annotations.Cache;
1819
import org.hibernate.annotations.CacheConcurrencyStrategy;
20+
import org.hibernate.annotations.Cascade;
1921
import org.hibernate.validator.constraints.NotEmpty;
2022

2123
/**
@@ -30,7 +32,7 @@
3032
@XmlAccessorType(XmlAccessType.FIELD)
3133
public class PurchaseGroup extends BaseModelObject {
3234

33-
@ManyToMany
35+
@ManyToMany(cascade = CascadeType.ALL)
3436
private Set<PurchaseItem> items = new HashSet<>();
3537

3638
@ManyToOne
@@ -44,7 +46,6 @@ public class PurchaseGroup extends BaseModelObject {
4446
protected String label;
4547

4648
@ManyToOne
47-
@NotNull
4849
@XmlTransient
4950
protected EventSignup eventSignup;
5051

src/main/java/com/devnexus/ting/core/model/registration/PurchaseItem.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
public class PurchaseItem extends BaseModelObject {
2828

2929
@ManyToOne
30-
@NotNull
3130
@XmlTransient
3231
private PurchaseGroup purchaseGroup;
3332

@@ -44,7 +43,7 @@ public class PurchaseItem extends BaseModelObject {
4443
@Size(max = 255)
4544
private String value;
4645

47-
@NotEmpty
46+
@NotNull
4847
private BigDecimal price;
4948

5049
@Temporal(TemporalType.DATE)

0 commit comments

Comments
 (0)