Skip to content

Commit 5e56ba8

Browse files
author
Eugen
committed
Merge pull request eugenp#9 from egmp777/master
Corrections After the Merge Today
2 parents 9f0d14b + ade8cb5 commit 5e56ba8

3 files changed

Lines changed: 163 additions & 159 deletions

File tree

‎spring-hibernate4/src/main/java/org/baeldung/persistence/model/Bar.java‎

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22

33
import java.io.Serializable;
44
import java.util.Set;
5-
import com.google.common.collect.Sets;
6-
import javax.persistence.*;
5+
6+
import javax.persistence.CascadeType;
7+
import javax.persistence.Entity;
8+
import javax.persistence.FetchType;
9+
import javax.persistence.GeneratedValue;
10+
import javax.persistence.GenerationType;
11+
import javax.persistence.Id;
12+
import javax.persistence.NamedQuery;
13+
import javax.persistence.OneToMany;
14+
715
import org.hibernate.annotations.OrderBy;
816

17+
import com.google.common.collect.Sets;
18+
919
@Entity
1020
@NamedQuery(name = "Bar.findAll", query = "SELECT b FROM Bar b")
1121
public class Bar implements Serializable {
@@ -16,7 +26,7 @@ public Bar() {
1626

1727
public Bar(final String name) {
1828
super();
19-
29+
2030
this.name = name;
2131
}
2232

@@ -31,41 +41,42 @@ public Bar(final String name) {
3141
@OrderBy(clause = "NAME DESC")
3242
Set<Foo> fooSet = Sets.newHashSet();
3343

34-
//API
35-
44+
// API
45+
3646
public Set<Foo> getFooSet() {
3747
return fooSet;
3848
}
39-
49+
4050
public void setFooSet(final Set<Foo> fooSet) {
4151
this.fooSet = fooSet;
4252
}
4353

4454
public int getId() {
45-
return this.id;
55+
return id;
4656
}
4757

4858
public void setId(final int id) {
4959
this.id = id;
5060
}
5161

5262
public String getName() {
53-
return this.name;
63+
return name;
5464
}
5565

5666
public void setName(final String name) {
5767
this.name = name;
5868
}
69+
5970
//
60-
71+
6172
@Override
6273
public int hashCode() {
6374
final int prime = 31;
6475
int result = 1;
6576
result = prime * result + ((name == null) ? 0 : name.hashCode());
6677
return result;
6778
}
68-
79+
6980
@Override
7081
public boolean equals(final Object obj) {
7182
if (this == obj)
@@ -82,13 +93,12 @@ public boolean equals(final Object obj) {
8293
return false;
8394
return true;
8495
}
85-
96+
8697
@Override
8798
public String toString() {
8899
final StringBuilder builder = new StringBuilder();
89100
builder.append("Bar [name=").append(name).append("]");
90101
return builder.toString();
91102
}
92103

93-
94104
}

‎spring-hibernate4/src/main/java/org/baeldung/persistence/model/Foo.java‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public Foo() {
2121
super();
2222

2323
}
24+
25+
public Foo(final String name) {
26+
super();
27+
this.name = name;
28+
}
29+
2430
@Id
2531
@GeneratedValue(strategy = GenerationType.AUTO)
2632
private long id;
@@ -38,25 +44,18 @@ public void setBar(final Bar bar) {
3844
this.bar = bar;
3945
}
4046

41-
public int getBar_Id() {
42-
return bar_Id;
43-
}
44-
45-
public void setBar_Id(final int bar_Id) {
46-
this.bar_Id = bar_Id;
47-
}
48-
49-
private int bar_Id;
50-
5147
public long getId() {
5248
return id;
5349
}
50+
5451
public void setId(final long id) {
5552
this.id = id;
5653
}
54+
5755
public String getName() {
5856
return name;
5957
}
58+
6059
public void setName(final String name) {
6160
this.name = name;
6261
}

0 commit comments

Comments
 (0)