Commit e0a7dcf7 by Tuomas Riihimäki

Add batchFetch for fetching place references. Speeds up init considerably

1 parent 9914e624
......@@ -32,6 +32,9 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.eclipse.persistence.annotations.BatchFetch;
import org.eclipse.persistence.annotations.BatchFetchType;
import fi.codecrew.moya.utilities.NumericStringComparator;
/**
......@@ -69,6 +72,7 @@ public class Place extends GenericEntity implements Comparable<Place> {
private String code = "";
@OneToOne(mappedBy = "placeReservation")
@BatchFetch(BatchFetchType.EXISTS)
private GroupMembership placeReserver;
@Column(name = "buyable", nullable = false)
......@@ -104,6 +108,11 @@ public class Place extends GenericEntity implements Comparable<Place> {
@ManyToOne
private EventUser currentUser;
@OneToOne(mappedBy = "place")
@JoinColumn(nullable = true)
@BatchFetch(BatchFetchType.EXISTS)
private PlaceSlot reserverSlot;
public static enum PlaceState {
FREE, DISABLED, LOCKED, TEMP_RESERVED_FORME,
MY_PLACE, RESERVED
......@@ -138,10 +147,6 @@ public class Place extends GenericEntity implements Comparable<Place> {
return ret;
}
@OneToOne(mappedBy = "place")
@JoinColumn(nullable = true)
private PlaceSlot reserverSlot;
public Place() {
super();
}
......@@ -311,6 +316,7 @@ public class Place extends GenericEntity implements Comparable<Place> {
/**
* NOTE: you can newer be sure that this is up to date
*
* @return
*/
public PlaceSlot getReserverSlot() {
......@@ -361,13 +367,13 @@ public class Place extends GenericEntity implements Comparable<Place> {
if (this.getName() == null || o.getName() == null) {
if (this.getName() == null) {
return 1;
}
}
if (o.getName() == null) {
return -1;
}
return -1;
}
// both names are null. Compare IDs
return this.getNonNullId().compareTo(o.getNonNullId());
}
}
if (this.getName().equals(o.getName())) {
return 0;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!