Revision from Predrag's feedback

This commit is contained in:
Rudi Adianto 2018-08-13 13:39:01 +07:00
parent 413c02c078
commit b424ae7ab2
3 changed files with 19 additions and 13 deletions

View File

@ -5,11 +5,15 @@ import javax.persistence.*;
@Entity @Entity
@Table(name = "Football_Player") @Table(name = "Football_Player")
public class FootballPlayer { public class FootballPlayer {
@Id @GeneratedValue private long id; @Id
@GeneratedValue
private long id;
@Column private String name; @Column
private String name;
@Column private String team; @Column
private String club;
public long getId() { public long getId() {
return id; return id;
@ -27,15 +31,16 @@ public class FootballPlayer {
this.name = name; this.name = name;
} }
public String getTeam() { public String getClub() {
return team; return club;
} }
public void setTeam(String team) { public void setClub(String club) {
this.team = team; this.club = club;
} }
@Override public String toString() { @Override
return "FootballPlayer{" + "id=" + id + ", name='" + name + '\'' + ", team='" + team + '\'' + '}'; public String toString() {
return "FootballPlayer{" + "id=" + id + ", name='" + name + '\'' + ", club='" + club + '\'' + '}';
} }
} }

View File

@ -97,6 +97,7 @@ public class HibernateLifecycleUnitTest {
session.update(messi); session.update(messi);
transaction.commit(); transaction.commit();
assertThat(getDirtyEntities()).size().isEqualTo(1); assertThat(getDirtyEntities()).size().isEqualTo(1);
assertThat(getDirtyEntities().get(0).getName()).isEqualTo("Leo Messi");
} }
} }

View File

@ -2,25 +2,25 @@ create sequence hibernate_sequence start with 1 increment by 1;
create table Football_Player ( create table Football_Player (
id bigint not null, id bigint not null,
team varchar(255), club varchar(255),
name varchar(255), name varchar(255),
primary key (id) primary key (id)
); );
insert into insert into
Football_Player Football_Player
(team, name, id) (club, name, id)
values values
('Juventus', 'Cristiano Ronaldo', next value for hibernate_sequence); ('Juventus', 'Cristiano Ronaldo', next value for hibernate_sequence);
insert into insert into
Football_Player Football_Player
(team, name, id) (club, name, id)
values values
('Barcelona', 'Lionel Messi', next value for hibernate_sequence); ('Barcelona', 'Lionel Messi', next value for hibernate_sequence);
insert into insert into
Football_Player Football_Player
(team, name, id) (club, name, id)
values values
('PSG', 'Gigi Buffon', next value for hibernate_sequence); ('PSG', 'Gigi Buffon', next value for hibernate_sequence);