rsanchez
2015-09-30 a9f3df010deef70c1e378148f008aeaa147bcf82
#0 fix - Changes persist() by merge() when license exists
2 files modified
changed files
securis/src/main/java/net/curisit/securis/db/License.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/ApiResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/License.java
....@@ -70,7 +70,7 @@
7070
7171 @Id
7272 @GeneratedValue
73
- private int id;
73
+ private Integer id;
7474
7575 private String code;
7676
....@@ -147,7 +147,7 @@
147147 @JsonIgnore
148148 private List<LicenseHistory> history;
149149
150
- public int getId() {
150
+ public Integer getId() {
151151 return id;
152152 }
153153
....@@ -269,7 +269,7 @@
269269 this.email = email;
270270 }
271271
272
- public void setId(int id) {
272
+ public void setId(Integer id) {
273273 this.id = id;
274274 }
275275
securis/src/main/java/net/curisit/securis/services/ApiResource.java
....@@ -420,7 +420,11 @@
420420 if (lic.getFullName() == null || "".equals(lic.getFullName())) {
421421 lic.setFullName(nameOrReference);
422422 }
423
- em.persist(lic);
423
+ if (lic.getId() != null) {
424
+ em.merge(lic);
425
+ } else {
426
+ em.persist(lic);
427
+ }
424428 em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.CREATE));
425429 if (lic.getActivationCode() != null) {
426430 em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.ACTIVATE, "Activated by code on creation"));