From 9c3a57236022bd25556824db65098c3a0f909ed5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 14 Feb 2013 19:53:09 +1300 Subject: Enabled eager fetching (fix #11) --- src/org/traccar/web/shared/model/Device.java | 3 ++- src/org/traccar/web/shared/model/Position.java | 5 ++--- src/org/traccar/web/shared/model/User.java | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/web/shared/model/Device.java b/src/org/traccar/web/shared/model/Device.java index d638046e..0b5fe30a 100644 --- a/src/org/traccar/web/shared/model/Device.java +++ b/src/org/traccar/web/shared/model/Device.java @@ -19,6 +19,7 @@ import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToOne; @@ -47,7 +48,7 @@ public class Device implements Serializable { return id; } - @OneToOne + @OneToOne(fetch = FetchType.EAGER) private Position latestPosition; public Position getLatestPosition() { diff --git a/src/org/traccar/web/shared/model/Position.java b/src/org/traccar/web/shared/model/Position.java index d5fa9a91..d9ec3b3f 100644 --- a/src/org/traccar/web/shared/model/Position.java +++ b/src/org/traccar/web/shared/model/Position.java @@ -19,6 +19,7 @@ import java.io.Serializable; import java.util.Date; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToOne; @@ -26,8 +27,6 @@ import javax.persistence.Table; import org.hibernate.annotations.Index; -//INSERT INTO positions (device_id, valid, time, latitude, longitude, altitude, speed, course) VALUES (11, 1, NOW(), 60, 30, 0, 0, 0); - @Entity @Table(name = "positions") public class Position implements Serializable, Cloneable { @@ -60,7 +59,7 @@ public class Position implements Serializable, Cloneable { return id; } - @ManyToOne + @ManyToOne(fetch = FetchType.EAGER) @Index(name = "positionsIndex") private Device device; diff --git a/src/org/traccar/web/shared/model/User.java b/src/org/traccar/web/shared/model/User.java index dcfd6b29..89bebc07 100644 --- a/src/org/traccar/web/shared/model/User.java +++ b/src/org/traccar/web/shared/model/User.java @@ -21,6 +21,7 @@ import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToMany; @@ -70,7 +71,7 @@ public class User implements Serializable, Cloneable { return password; } - @OneToMany + @OneToMany(fetch = FetchType.EAGER) private List devices = new LinkedList(); public List getDevices() { -- cgit v1.2.3