In this tutorial, we will cover the most basic features of JPMapper. For the moment, let's use the following database schema and class:



Class user:
import jpmapper.core.ID;
import jpmapper.core.FOREING;

public class User{
@ID
int userID;
String name;
String password;
@FOREING
Groupe groupe;

public void setUserID(int userID){
this.userID=userID;
}
public int getUserID(){
return userID;
}

public void setGroupe(Groupe groupe){
this.groupe=groupe;
}
public Groupe getGroupe(){
return groupe;
}
...//setters and getters
}

Class groupe:
import jpmapper.core.ID;

public class Groupe {
@ID
int groupeID;
String name;
String description;

public void setGroupeID(int gID){
this.groupeID=groupeID;
}
public int getGroupeID(){
return groupeID;
}
...//setters and getters
}

DB Schema: (MySQL DBMS)
CREATE TABLE `User` ( `userID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR( 20 ) NULL , `password` VARCHAR( 20 ) NULL , `groupeID` INT NULL , INDEX ( `groupeID` ) ) ENGINE = InnoDB;

CREATE TABLE `Groupe` ( `groupeID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR( 20 ) NULL , `description` VARCHAR( 20 ) NULL ) ENGINE = InnoDB;

ALTER TABLE `user` ADD FOREIGN KEY ( `groupeID` ) REFERENCES `jpmapperTest`.`groupe` ( `groupeID` ) ON DELETE SET NULL ON UPDATE SET NULL ;

(please come back later to get the updated version of this tutorial)

START USING JPMAPPER!