hi, Im new to hibernate...
I have this entity class, the first one i built to test Hibernate, it uses an oracle sequence to fill the ID field :
@Entity
@Table(name="COMPANIES")
public class Companies {
private Integer cmpid;
private String cmpname;
private String cmpcountry;
public Companies() {
}
public Companies(String name, String country) {
this.cmpname = name;
this.cmpcountry = country;
}
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "gen_CMP")
@SequenceGenerator(name="gen_CMP", sequenceName = "CMP_ID_SEQ")
@Column(name="CMP_ID", nullable=false)
public Integer getCmpId() {
return this.cmpid;
}
public void setCmpId(Integer cmpid) {
this.cmpid = cmpid;
}
@Column(name="CMP_NAME", nullable=true)
public String getCmpName() {
return this.cmpname;
}
public void setCmpName(String cmpname) {
this.cmpname = cmpname;
}
@Column(name="CMP_COUNTRY", nullable=true)
public String getCmpCountry() {
return this.cmpcountry;
}
public void setCmpCountry(String cmpcountry) {
this.cmpcountry = cmpcountry;
}
}
Then in my Test Unit, i create a Companies object then save it in the session :
Companies Companies = new Companies("qqq","FR");
session.save(Companies);
transaction.commit();
But everytime, it delete ALL the records in the COMPANIES table in Oracle.
So the first time i tried on my data, it was filled with many rows, and with this primary keys used in other tables, and it was able to delete those rows in Companies and not the other tables...
So it means Hibernate actually disabled all my constraints, empty the table, and added the new row from my Test Unit...
What am i doing wrong?
I dont want hibernate to mess with my data unless i tell it to do so...