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
@Table(name = "Football_Player")
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() {
return id;
@ -27,15 +31,16 @@ public class FootballPlayer {
this.name = name;
}
public String getTeam() {
return team;
public String getClub() {
return club;
}
public void setTeam(String team) {
this.team = team;
public void setClub(String club) {
this.club = club;
}
@Override public String toString() {
return "FootballPlayer{" + "id=" + id + ", name='" + name + '\'' + ", team='" + team + '\'' + '}';
@Override
public String toString() {
return "FootballPlayer{" + "id=" + id + ", name='" + name + '\'' + ", club='" + club + '\'' + '}';
}
}

View File

@ -97,6 +97,7 @@ public class HibernateLifecycleUnitTest {
session.update(messi);
transaction.commit();
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 (
id bigint not null,
team varchar(255),
club varchar(255),
name varchar(255),
primary key (id)
);
insert into
Football_Player
(team, name, id)
(club, name, id)
values
('Juventus', 'Cristiano Ronaldo', next value for hibernate_sequence);
insert into
Football_Player
(team, name, id)
(club, name, id)
values
('Barcelona', 'Lionel Messi', next value for hibernate_sequence);
insert into
Football_Player
(team, name, id)
(club, name, id)
values
('PSG', 'Gigi Buffon', next value for hibernate_sequence);