While using EJB3hibernateDAO plugin to generate java classes from DB and a city-person database as is in your example on http://salto-db.sourceforge.net/salto-db-generator/plugins/ejb3.html Imagine, that the every person will have another column id_city2 int(11) NOT NULL for alternate address. So the table will look like :
CREATE TABLE person (
id_person int(11) NOT NULL auto_increment,
name varchar(50) NOT NULL,
first_name varchar(50) NOT NULL,
age int(11) NOT NULL,
id_city int(11) NOT NULL, id_city2 int(11) NOT NULL,
PRIMARY KEY (id_person),
KEY fk_person_city (id_city), KEY fk_person_city (id_city2),
CONSTRAINT fk_person_city FOREIGN KEY (id_city) REFERENCES city (id_city) CONSTRAINT fk_person_city2 FOREIGN KEY (id_city2) REFERENCES city (id_city2)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Then the class Person.java will have this code iside:
/**
* Attribute city
*/
private City city;
/**
* Attribute city
*/
private City city; That means, that the attribute will be doubled as well as accessor methods. Also attributes and accessor methods in City.java class will be doubled: ... /**
* List of Person
*/
private List<Person> persons = null; /**
* List of Person
*/
private List<Person> persons = null; ... Instead of this behaviour, we would expect variable names same as column names (optionaly with FK prefix or whatever)