我花了3天时间寻找这些错误背后的原因,我需要使用特定的框架EclipseLink将这3个表实体映射到PostgreSQL,当然这三个实体之间存在关系:
组
t = 0
duration = 10
num_strings = 5
while t < 10:
print(round((t*num_strings/duration)%1, 3))
t += .1
人
package com.sagemcom.tn.entities;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
*
* @author G557437
*/
@Entity
@Table(name = "GROUPE", catalog = "", schema = "SYNCPKTME")
@NamedQueries({
@NamedQuery(name = "Groupe.findAll", query = "SELECT g FROM Groupe g")})
public class Groupe implements Serializable {
private static final long serialVersionUID = 1L;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Id
@Basic(optional = false)
@NotNull
@Column(name = "IDGROUPE")
private BigDecimal idgroupe;
@Size(max = 45)
@Column(name = "NOMGROUPE")
private String nomgroupe;
@Size(max = 45)
@Column(name = "LIBELLE")
private String libelle;
@Size(max = 10)
@Column(name = "CREE_PAR")
private String creePar;
@Column(name = "DATE_CREATION")
@Temporal(TemporalType.TIMESTAMP)
private Date dateCreation;
@Size(max = 45)
@Column(name = "MAJ_PAR")
private String majPar;
@Column(name = "DATE_MAJ")
@Temporal(TemporalType.TIMESTAMP)
private Date dateMaj;
@OneToMany(mappedBy = "idgroupe")
private List<PersonneGroupe> personneGroupeList;
public Groupe() {
}
public Groupe(BigDecimal idgroupe) {
this.idgroupe = idgroupe;
}
public BigDecimal getIdgroupe() {
return idgroupe;
}
public void setIdgroupe(BigDecimal idgroupe) {
this.idgroupe = idgroupe;
}
public String getNomgroupe() {
return nomgroupe;
}
public void setNomgroupe(String nomgroupe) {
this.nomgroupe = nomgroupe;
}
public String getLibelle() {
return libelle;
}
public void setLibelle(String libelle) {
this.libelle = libelle;
}
public String getCreePar() {
return creePar;
}
public void setCreePar(String creePar) {
this.creePar = creePar;
}
public Date getDateCreation() {
return dateCreation;
}
public void setDateCreation(Date dateCreation) {
this.dateCreation = dateCreation;
}
public String getMajPar() {
return majPar;
}
public void setMajPar(String majPar) {
this.majPar = majPar;
}
public Date getDateMaj() {
return dateMaj;
}
public void setDateMaj(Date dateMaj) {
this.dateMaj = dateMaj;
}
public List<PersonneGroupe> getPersonneGroupeList() {
return personneGroupeList;
}
public void setPersonneGroupeList(List<PersonneGroupe> personneGroupeList) {
this.personneGroupeList = personneGroupeList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idgroupe != null ? idgroupe.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Groupe)) {
return false;
}
Groupe other = (Groupe) object;
if ((this.idgroupe == null && other.idgroupe != null) || (this.idgroupe != null && !this.idgroupe.equals(other.idgroupe))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.sagemcom.tn.entities.lot1.Groupe[ idgroupe=" + idgroupe + " ]";
}
}
PersonGroup
package com.sagemcom.tn.entities;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
*
* @author G557437
*/
@Entity
@Table(name = "PERSONNE", schema = "SYNCPKTME")
public class Personne implements Serializable {
private static final long serialVersionUID = 1L;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Id
@Basic(optional = false)
@NotNull
@Column(name = "IDPERSONNE")
private BigDecimal idpersonne;
@Size(max = 10)
@Column(name = "MATRICULE")
private String matricule;
@Size(max = 45)
@Column(name = "NOM")
private String nom;
@Size(max = 45)
@Column(name = "PRENOM")
private String prenom;
@Size(max = 45)
@Column(name = "UTILISATEUR")
private String utilisateur;
@Size(max = 10)
@Column(name = "CREE_PAR")
private String creePar;
@Column(name = "DATE_CREATION")
@Temporal(TemporalType.TIMESTAMP)
private Date dateCreation;
@Size(max = 45)
@Column(name = "MAJ_PAR")
private String majPar;
@Column(name = "DATE_MAJ")
@Temporal(TemporalType.TIMESTAMP)
private Date dateMaj;
@OneToMany(mappedBy = "idpersonne")
private List<PersonneGroupe> personneGroupeList;
public Personne() {
}
public Personne(BigDecimal idpersonne) {
this.idpersonne = idpersonne;
}
public BigDecimal getIdpersonne() {
return idpersonne;
}
public void setIdpersonne(BigDecimal idpersonne) {
this.idpersonne = idpersonne;
}
public String getMatricule() {
return matricule;
}
public void setMatricule(String matricule) {
this.matricule = matricule;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getUtilisateur() {
return utilisateur;
}
public void setUtilisateur(String utilisateur) {
this.utilisateur = utilisateur;
}
public String getCreePar() {
return creePar;
}
public void setCreePar(String creePar) {
this.creePar = creePar;
}
public Date getDateCreation() {
return dateCreation;
}
public void setDateCreation(Date dateCreation) {
this.dateCreation = dateCreation;
}
public String getMajPar() {
return majPar;
}
public void setMajPar(String majPar) {
this.majPar = majPar;
}
public Date getDateMaj() {
return dateMaj;
}
public void setDateMaj(Date dateMaj) {
this.dateMaj = dateMaj;
}
public List<PersonneGroupe> getPersonneGroupeList() {
return personneGroupeList;
}
public void setPersonneGroupeList(List<PersonneGroupe> personneGroupeList) {
this.personneGroupeList = personneGroupeList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idpersonne != null ? idpersonne.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Personne)) {
return false;
}
Personne other = (Personne) object;
if ((this.idpersonne == null && other.idpersonne != null) || (this.idpersonne != null && !this.idpersonne.equals(other.idpersonne))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.sagemcom.tn.entities.lot1.Personne[ idpersonne=" + idpersonne + " ]";
}
}
这是package com.sagemcom.tn.entities;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
*
* @author G557437
*/
@Entity
@Table(name = "PERSONNE_GROUPE", schema = "SYNCPKTME")
@NamedQueries({
@NamedQuery(name = "PersonneGroupe.findAll", query = "SELECT p FROM PersonneGroupe p")})
public class PersonneGroupe implements Serializable {
private static final long serialVersionUID = 1L;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Id
@Basic(optional = false)
@NotNull
@Column(name = "IDPERSONNEGROUPE")
private BigDecimal idpersonnegroupe;
@Size(max = 255)
@Column(name = "CREE_PAR")
private String creePar;
@Column(name = "DATE_CREATION")
@Temporal(TemporalType.TIMESTAMP)
private Date dateCreation;
@Column(name = "DATE_MAJ")
@Temporal(TemporalType.TIMESTAMP)
private Date dateMaj;
@Size(max = 255)
@Column(name = "MAJ_PAR")
private String majPar;
@Size(max = 255)
@Column(name = "UTILISATEUR")
private String utilisateur;
@JoinColumn(name = "IDPERSONNE", referencedColumnName = "IDPERSONNE")
@ManyToOne
private Personne idpersonne;
@JoinColumn(name = "IDGROUPE", referencedColumnName = "IDGROUPE")
@ManyToOne
private Groupe idgroupe;
public PersonneGroupe() {
}
public PersonneGroupe(BigDecimal idpersonnegroupe) {
this.idpersonnegroupe = idpersonnegroupe;
}
public BigDecimal getIdpersonnegroupe() {
return idpersonnegroupe;
}
public void setIdpersonnegroupe(BigDecimal idpersonnegroupe) {
this.idpersonnegroupe = idpersonnegroupe;
}
public String getCreePar() {
return creePar;
}
public void setCreePar(String creePar) {
this.creePar = creePar;
}
public Date getDateCreation() {
return dateCreation;
}
public void setDateCreation(Date dateCreation) {
this.dateCreation = dateCreation;
}
public Date getDateMaj() {
return dateMaj;
}
public void setDateMaj(Date dateMaj) {
this.dateMaj = dateMaj;
}
public String getMajPar() {
return majPar;
}
public void setMajPar(String majPar) {
this.majPar = majPar;
}
public String getUtilisateur() {
return utilisateur;
}
public void setUtilisateur(String utilisateur) {
this.utilisateur = utilisateur;
}
public Personne getIdpersonne() {
return idpersonne;
}
public void setIdpersonne(Personne idpersonne) {
this.idpersonne = idpersonne;
}
public Groupe getIdgroupe() {
return idgroupe;
}
public void setIdgroupe(Groupe idgroupe) {
this.idgroupe = idgroupe;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idpersonnegroupe != null ? idpersonnegroupe.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof PersonneGroupe)) {
return false;
}
PersonneGroupe other = (PersonneGroupe) object;
if ((this.idpersonnegroupe == null && other.idpersonnegroupe != null) || (this.idpersonnegroupe != null && !this.idpersonnegroupe.equals(other.idpersonnegroupe))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.sagemcom.tn.entities.lot1.PersonneGroupe[ idpersonnegroupe=" + idpersonnegroupe + " ]";
}
}
文件:
pom.xml
在构建项目时,我得到了这个:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>synchroProject</groupId>
<artifactId>synchroProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</project>
答案 0 :(得分:3)
javax.persistence:persistence-api:1.0.2
来自24-Jul-2007。
我使用21-Aug-2017中的javax.persistence:javax.persistence-api:2.2
代替。
maven-compiler-plugin
?这导致了警告:
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-compiler-plugin @ line 27, column 15
这也不好:
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
我在IDE中将编码更改为UTF-8并使用POM properties:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
这样您就可以完全放弃这些maven-compiler-plugin
声明,因为默认情况下compiler:compile和site:site都使用了所有这些属性。