Skip to content

Commit

Permalink
Fixed issue with allocation persisting
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogoevici authored and pmuir committed May 28, 2012
1 parent 21bda00 commit e91e194
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Expand Up @@ -6,18 +6,21 @@

import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

/**
* An allocation consists of one or more contiguous sold seats
* within a SectionRow.
*
* @author Shane Bryzak
* @author Marius Bogoevici
*/
@Entity
@Entity @JsonIgnoreProperties("booking")
public class Allocation implements Serializable {
private static final long serialVersionUID = 8738724150877088864L;

Expand All @@ -31,7 +34,7 @@ public class Allocation implements Serializable {
@ManyToOne
private Booking booking;

@ElementCollection
@ElementCollection(fetch = FetchType.EAGER)
public List<AllocationTicketCategoryCount> ticketsPerCategory = new ArrayList<AllocationTicketCategoryCount>();

private int startSeat;
Expand Down
Expand Up @@ -4,6 +4,7 @@
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
Expand All @@ -28,7 +29,7 @@ public class Booking {
@GeneratedValue
private Long id;

@OneToMany(fetch = FetchType.EAGER, mappedBy = "booking")
@OneToMany(fetch = FetchType.EAGER, mappedBy = "booking",cascade = CascadeType.ALL)
@NotEmpty
@Valid
private Set<Allocation> allocations = new HashSet<Allocation>();
Expand Down
Expand Up @@ -125,8 +125,8 @@ public Response createBooking(@FormParam("email") String email,
return Response.status(Response.Status.NOT_MODIFIED).build();
}
createdAllocation.setTicketsPerCategory(ticketsPerCategory.get(sectionId));
getEntityManager().persist(createdAllocation);
booking.getAllocations().add(createdAllocation);
System.out.println("Allocating " + createdAllocation.getQuantity() + " tickets ");
booking.addAllocation(createdAllocation);
}
booking.setPerformance(performance);
booking.setCancellationCode("abc");
Expand Down

0 comments on commit e91e194

Please sign in to comment.