Hola:
Para insertar el objeto Issue uso el siguiente código:
Código C:
Ver originalIssueService is = new IssueService();
Issue i1 = new Issue();
is.add(i1);
- Clase Issue
Código C:
Ver original@Entity
@Table(name = "table_issue")
public class Issue implements IIssue {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "issueNumber", unique = true)
private int issueNumber;
@Column(name = "name")
private String name;
@Column(name = "email", unique = true)
private String email;
@Column(name = "description")
private String description;
@ManyToOne(cascade = CascadeType.PERSIST, targetEntity = Product.class)
@JoinColumn(name = "code_p")
private IProduct product;
@ManyToOne(cascade = CascadeType.PERSIST, targetEntity = MaintenanceProcedure.class)
@JoinColumn(name = "code_mp")
private IMaintenanceProcedure maintenanceProcedure;
@ManyToOne(cascade = CascadeType.PERSIST, targetEntity = Technician.class)
@JoinColumn(name = "technicianNumber")
private ITechnician technician;
@Column(name = "response")
private String response;
@Column(name = "punctuation")
private int punctuation;
@ManyToMany(cascade = CascadeType.PERSIST, targetEntity = Issue.class)
@JoinColumn(name = "issueNumber")
private Set<IIssue> recordList = new HashSet<IIssue>();
(...)
- Clase MaintenaceProcedure
Código C:
Ver original@Entity
@Table(name = "table_maintenanceProcedure")
public class MaintenanceProcedure implements IMaintenanceProcedure {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "code_mp", unique = true)
private int code_mp;
@Column(name = "name", unique = true)
private String name;
@Column(name = "description")
private String description;
@ManyToMany(cascade = CascadeType.PERSIST, targetEntity = Product.class)
@JoinColumn(name = "code_p")
private Set<IProduct> productList = new HashSet<IProduct>();
@ManyToMany(cascade = CascadeType.PERSIST, targetEntity = Technician.class)
@JoinColumn(name = "technicianNumber")
private Set<ITechnician> technicianList = new HashSet<ITechnician>();
@OneToMany(mappedBy = "issueNumber", cascade = CascadeType.PERSIST, targetEntity = Issue.class)
private Set<IIssue> issueList = new HashSet<IIssue>();
(...)
- Clase Technician
Código C:
Ver original@Entity
@Table(name = "table_technician")
public class Technician implements ITechnician {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "technicianNumber", unique = true)
private int technicianNumber;
@Column(name = "email", unique = true)
private String email;
@Column(name = "password")
private String password;
@Column(name = "name")
private String name;
@Column(name = "lastname")
private String lastname;
@Column(name = "city")
private String city;
@Column(name = "country")
private String country;
@ManyToMany(cascade = CascadeType.PERSIST, targetEntity = MaintenanceProcedure.class)
@JoinColumn(name = "code_mp")
private Set<IMaintenanceProcedure> maintenanceProcedureList;
@OneToMany(mappedBy = "issueNumber", cascade = CascadeType.PERSIST, targetEntity = Issue.class)
private Set<IIssue> issueList;
(...)
- Clase Product
Código C:
Ver original@Entity
@Table(name = "table_product")
public class Product implements IProduct {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "code_p", unique = true)
private int code_p;
@Column(name = "name", unique = true)
private String name;
@Column(name = "description")
private String description;
@ManyToMany(cascade = CascadeType.PERSIST, targetEntity = MaintenanceProcedure.class)
@JoinColumn(name = "code_mp")
private Set<IMaintenanceProcedure> maintenanceProcedureList;
@OneToMany(mappedBy = "issueNumber", cascade = CascadeType.PERSIST, targetEntity = Issue.class)
private Set<IIssue> issueList;
(...)