I have created a simple class and a simple tables of database to test the hibernate concepts. The class is named "Employee":
public class Employee {
private String firstName;
private String lastName;
private int salary;
public Employee(String fname, String lname, int salary) {
this.firstName = fname;
this.lastName = lname;
this.salary = salary;
}
...
}
The database names "EMPLOYEE":
create table EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
This is my Employee.hbm.xml:
<hibernate-mapping>
<class name="Employee" table="EMPLOYEE">
<id name="id" type="int" column="id">
<generator class="native"/>
</id>
...
...
</class>
</hibernate-mapping>
So, you can notice that in my class it doesn't have the "id" attribute. However, I create the id column in my database to let it be the primary key which is automatically generated. In this case, I don't know what should I put in the <id name="?" type="int" column="id"> to map my class with my database. If I ignore it, would it be some problems afterward?