#0 fix - Changes persist() by merge() when license exists
| .. | .. |
|---|
| 70 | 70 | |
|---|
| 71 | 71 | @Id |
|---|
| 72 | 72 | @GeneratedValue |
|---|
| 73 | | - private int id; |
|---|
| 73 | + private Integer id; |
|---|
| 74 | 74 | |
|---|
| 75 | 75 | private String code; |
|---|
| 76 | 76 | |
|---|
| .. | .. |
|---|
| 147 | 147 | @JsonIgnore |
|---|
| 148 | 148 | private List<LicenseHistory> history; |
|---|
| 149 | 149 | |
|---|
| 150 | | - public int getId() { |
|---|
| 150 | + public Integer getId() { |
|---|
| 151 | 151 | return id; |
|---|
| 152 | 152 | } |
|---|
| 153 | 153 | |
|---|
| .. | .. |
|---|
| 269 | 269 | this.email = email; |
|---|
| 270 | 270 | } |
|---|
| 271 | 271 | |
|---|
| 272 | | - public void setId(int id) { |
|---|
| 272 | + public void setId(Integer id) { |
|---|
| 273 | 273 | this.id = id; |
|---|
| 274 | 274 | } |
|---|
| 275 | 275 | |
|---|
| .. | .. |
|---|
| 420 | 420 | if (lic.getFullName() == null || "".equals(lic.getFullName())) { |
|---|
| 421 | 421 | lic.setFullName(nameOrReference); |
|---|
| 422 | 422 | } |
|---|
| 423 | | - em.persist(lic); |
|---|
| 423 | + if (lic.getId() != null) { |
|---|
| 424 | + em.merge(lic); |
|---|
| 425 | + } else { |
|---|
| 426 | + em.persist(lic); |
|---|
| 427 | + } |
|---|
| 424 | 428 | em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.CREATE)); |
|---|
| 425 | 429 | if (lic.getActivationCode() != null) { |
|---|
| 426 | 430 | em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.ACTIVATE, "Activated by code on creation")); |
|---|