From 7d9d5a220e8f79ce1bc0d4b9931dc0c848e99c43 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 14 Feb 2013 20:02:43 +1300 Subject: Actually remove device (fix #9) --- src/org/traccar/web/server/model/DataServiceImpl.java | 3 +-- src/org/traccar/web/shared/model/Device.java | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/web') diff --git a/src/org/traccar/web/server/model/DataServiceImpl.java b/src/org/traccar/web/server/model/DataServiceImpl.java index 57357aa..8113060 100644 --- a/src/org/traccar/web/server/model/DataServiceImpl.java +++ b/src/org/traccar/web/server/model/DataServiceImpl.java @@ -167,8 +167,7 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService try { device = entityManager.merge(device); user.getDevices().remove(device); - // If you want to remove device you need to remove all linked positions - //entityManager.remove(device); + entityManager.remove(device); entityManager.getTransaction().commit(); } catch (RuntimeException e) { entityManager.getTransaction().rollback(); diff --git a/src/org/traccar/web/shared/model/Device.java b/src/org/traccar/web/shared/model/Device.java index 0b5fe30..ede3c5f 100644 --- a/src/org/traccar/web/shared/model/Device.java +++ b/src/org/traccar/web/shared/model/Device.java @@ -17,6 +17,7 @@ package org.traccar.web.shared.model; import java.io.Serializable; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -48,7 +49,7 @@ public class Device implements Serializable { return id; } - @OneToOne(fetch = FetchType.EAGER) + @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.REMOVE) private Position latestPosition; public Position getLatestPosition() { -- cgit v1.2.3