lishman levelup
«previous  next»


Getting Started
Form Processing
IoC Container
Hibernate ORM



The Hibernate Enity


We will use Hibernate to access the data in this database table:

COUNTRY
CTRY_ID CTRY_NAME CTRY_AREA CTRY_POP POP_UPD_ON CURRENCY
14 Germany 137882 82046000 30-nov-08 Euro
48 Ghana 92100 23837000 null Cedi
53 Australia 2969907 21884000 4-sep-09 Australian Dollar
73 Greece 50949 11257285 1-Jan-09 Euro
122 Georgia 26900 4382100 1-Jan-09 Lari
123 New Zealand 104428 4320300 4-sep-09 New Zealand Dollar
147 Gambia 4361 1705000 null Dalasi
149 Gabon 103347 1475000 null CFA franc


So, first we need to modify our Country class to be a Hibernate entity:
@Entity
@Table(name="COUNTRY")
public class Country {

  @Id
  @GeneratedValue
  @Column(name="CTRY_ID")
  private Integer id;

  @Column(name="CTRY_NAME")
  private String name;

  @Column(name="CTRY_AREA")
  private Integer area;

  @Column(name="CTRY_POP")
  private Long population;

  @Column(name="POP_UPD_ON")
  private Date populationLastUpdated;

  @Column(name="CURRENCY")
  private String currency;

  ..

}
»