Merge branch '70-fix-duplicate-key-in-timetrackaccounts-tabe' into 'master'

Resolve "Fix duplicate key in timetrackAccounts table"

Closes #70

See merge request marcel.schwarz/2020ss-qbc-geofence-timetracking!43
This commit is contained in:
Marcel Schwarz 2020-05-11 18:33:19 +00:00
commit 7cd4d52138
3 changed files with 8 additions and 12 deletions

View File

@ -1,13 +1,11 @@
package de.hft.geotime.timetrackaccount; package de.hft.geotime.timetrackaccount;
import de.hft.geotime.user.TimetrackUser;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.persistence.Entity; import javax.persistence.*;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -21,5 +19,7 @@ public class TimetrackAccount {
private double revenue; private double revenue;
private String name; private String name;
private String description; private String description;
@ManyToOne
private TimetrackUser user;
} }

View File

@ -33,7 +33,7 @@ public class TimetrackUser {
@OneToOne @OneToOne
private Role role; private Role role;
@OneToMany(fetch = FetchType.LAZY) @OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<TimetrackAccount> accounts; private List<TimetrackAccount> accounts;
} }

View File

@ -6,10 +6,6 @@ DELETE FROM role;
INSERT INTO role (id, `name`) VALUES INSERT INTO role (id, `name`) VALUES
(1, 'Admin'); (1, 'Admin');
INSERT INTO timetrack_account (id, description, `name`, revenue) VALUES
(1, 'Gleitzeit Marcel', 'Primary Marcel', 16.0),
(2, 'Festgeld Marcel', 'Secondary Marcel', 25.0);
/* password is the firstname in lowercase e.g. marcel or tobias /* password is the firstname in lowercase e.g. marcel or tobias
https://bcrypt-generator.com/ with 10 rounds https://bcrypt-generator.com/ with 10 rounds
*/ */
@ -19,8 +15,8 @@ INSERT INTO timetrack_user (id, firstname, lastname, password, username, role_id
(3, 'Tim', 'Zieger' ,'$2y$10$pYGHZhoaelceImO7aIN4nOkWJBp.oqNGFYaRAonHkYF4u9ljqPelC', 'ziti', 1), (3, 'Tim', 'Zieger' ,'$2y$10$pYGHZhoaelceImO7aIN4nOkWJBp.oqNGFYaRAonHkYF4u9ljqPelC', 'ziti', 1),
(4, 'Simon', 'Kellner' ,'$2y$10$Puzm/Nr/Dyq3nQxlkXGIfubS5JPtXJSOf2e6mrQ6HhVYQN9YiQQsC', 'kesi', 1); (4, 'Simon', 'Kellner' ,'$2y$10$Puzm/Nr/Dyq3nQxlkXGIfubS5JPtXJSOf2e6mrQ6HhVYQN9YiQQsC', 'kesi', 1);
INSERT INTO timetrack_user_accounts (timetrack_user_id, accounts_id) VALUES INSERT INTO timetrack_account (description, `name`, revenue, user_id) VALUES
(1, 1), ('Gleitzeit Marcel', 'Primary Marcel', 16.0, 1),
(1, 2); ('Festgeld Marcel', 'Secondary Marcel', 25.0, 1);
SET FOREIGN_KEY_CHECKS=1; SET FOREIGN_KEY_CHECKS=1;