Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7647903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:34:40+00:00 2026-05-31T10:34:40+00:00

I have the following tables : wherein idclient is unsigned auto_increment . code of

  • 0

I have the following tables :
enter image description here

enter image description here

wherein idclient is unsigned auto_increment.

code of the Client entity:

import java.io.Serializable;

import java.util.List;

import javax.persistence.*;

import javax.xml.bind.annotation.XmlRootElement;

import javax.xml.bind.annotation.XmlTransient;


@Entity
@Table(name = "CLIENT", catalog = "TEST", schema = "PUBLIC")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Client.findAll", query = "SELECT c FROM Client c"),
@NamedQuery(name = "Client.findByIdclient", query = "SELECT c FROM Client c WHERE c.idclient = :idclient"),
@NamedQuery(name = "Client.findByLibel", query = "SELECT c FROM Client c WHERE c.libel = :libel"),
@NamedQuery(name = "Client.findByAdresse", query = "SELECT c FROM Client c WHERE c.adresse = :adresse"),
@NamedQuery(name = "Client.findByNomResp", query = "SELECT c FROM Client c WHERE c.nomResp = :nomResp"),
@NamedQuery(name = "Client.findByTelPortable", query = "SELECT c FROM Client c WHERE c.telPortable = :telPortable"),
@NamedQuery(name = "Client.findByTelFixe", query = "SELECT c FROM Client c WHERE c.telFixe = :telFixe"),
@NamedQuery(name = "Client.findByFax", query = "SELECT c FROM Client c WHERE c.fax = :fax"),
@NamedQuery(name = "Client.findByCodeTva", query = "SELECT c FROM Client c WHERE c.codeTva = :codeTva"),
@NamedQuery(name = "Client.findByCodeExo", query = "SELECT c FROM Client c WHERE c.codeExo = :codeExo"),
@NamedQuery(name = "Client.findByBanque", query = "SELECT c FROM Client c WHERE c.banque = :banque"),
@NamedQuery(name = "Client.findByRib", query = "SELECT c FROM Client c WHERE c.rib = :rib"),
@NamedQuery(name = "Client.findByCredit", query = "SELECT c FROM Client c WHERE c.credit = :credit"),
@NamedQuery(name = "Client.findByEchance", query = "SELECT c FROM Client c WHERE c.echance = :echance"),
@NamedQuery(name = "Client.findByMail", query = "SELECT c FROM Client c WHERE c.mail = :mail"),
@NamedQuery(name = "Client.findByEtat", query = "SELECT c FROM Client c WHERE c.etat = :etat")})
public class Client implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "IDCLIENT", nullable = false)
private Integer idclient;
@Basic(optional = false)
@Column(name = "LIBEL", nullable = false, length = 100)
private String libel;
@Basic(optional = false)
@Column(name = "ADRESSE", nullable = false, length = 100)
private String adresse;
@Basic(optional = false)
@Column(name = "NOM_RESP", nullable = false, length = 60)
private String nomResp;
@Basic(optional = false)
@Column(name = "TEL_PORTABLE", nullable = false, length = 16)
private String telPortable;
@Basic(optional = false)
@Column(name = "TEL_FIXE", nullable = false, length = 16)
private String telFixe;
@Basic(optional = false)
@Column(name = "FAX", nullable = false, length = 16)
private String fax;
@Basic(optional = false)
@Column(name = "CODE_TVA", nullable = false, length = 30)
private String codeTva;
@Basic(optional = false)
@Column(name = "CODE_EXO", nullable = false, length = 30)
private String codeExo;
@Basic(optional = false)
@Column(name = "BANQUE", nullable = false, length = 60)
private String banque;
@Basic(optional = false)
@Column(name = "RIB", nullable = false, length = 22)
private String rib;
@Basic(optional = false)
@Column(name = "CREDIT", nullable = false)
private double credit;
@Basic(optional = false)
@Column(name = "ECHANCE", nullable = false)
private int echance;
@Basic(optional = false)
@Column(name = "MAIL", nullable = false, length = 70)
private String mail;
@Basic(optional = false)
@Column(name = "ETAT", nullable = false)
private char etat;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "clientIdclient")
private List<Facture> factureList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "clientIdclient")
private List<FactProforma> factProformaList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "clientIdclient")
private List<Bl> blList;

public Client() {
}

public Client(Integer idclient) {
    this.idclient = idclient;
}

public Client(Integer idclient, String libel, String adresse, String nomResp, String telPortable, String telFixe, String fax, String codeTva, String codeExo, String banque, String rib, double credit, int echance, String mail, char etat) {
    this.idclient = idclient;
    this.libel = libel;
    this.adresse = adresse;
    this.nomResp = nomResp;
    this.telPortable = telPortable;
    this.telFixe = telFixe;
    this.fax = fax;
    this.codeTva = codeTva;
    this.codeExo = codeExo;
    this.banque = banque;
    this.rib = rib;
    this.credit = credit;
    this.echance = echance;
    this.mail = mail;
    this.etat = etat;
}

public Integer getIdclient() {
    return idclient;
}

public void setIdclient(Integer idclient) {
    this.idclient = idclient;
}

public String getLibel() {
    return libel;
}

public void setLibel(String libel) {
    this.libel = libel;
}

public String getAdresse() {
    return adresse;
}

public void setAdresse(String adresse) {
    this.adresse = adresse;
}

public String getNomResp() {
    return nomResp;
}

public void setNomResp(String nomResp) {
    this.nomResp = nomResp;
}

public String getTelPortable() {
    return telPortable;
}

public void setTelPortable(String telPortable) {
    this.telPortable = telPortable;
}

public String getTelFixe() {
    return telFixe;
}

public void setTelFixe(String telFixe) {
    this.telFixe = telFixe;
}

public String getFax() {
    return fax;
}

public void setFax(String fax) {
    this.fax = fax;
}

public String getCodeTva() {
    return codeTva;
}

public void setCodeTva(String codeTva) {
    this.codeTva = codeTva;
}

public String getCodeExo() {
    return codeExo;
}

public void setCodeExo(String codeExo) {
    this.codeExo = codeExo;
}

public String getBanque() {
    return banque;
}

public void setBanque(String banque) {
    this.banque = banque;
}

public String getRib() {
    return rib;
}

public void setRib(String rib) {
    this.rib = rib;
}

public double getCredit() {
    return credit;
}

public void setCredit(double credit) {
    this.credit = credit;
}

public int getEchance() {
    return echance;
}

public void setEchance(int echance) {
    this.echance = echance;
}

public String getMail() {
    return mail;
}

public void setMail(String mail) {
    this.mail = mail;
}

public char getEtat() {
    return etat;
}

public void setEtat(char etat) {
    this.etat = etat;
}

@XmlTransient
public List<Facture> getFactureList() {
    return factureList;
}

public void setFactureList(List<Facture> factureList) {
    this.factureList = factureList;
}

@XmlTransient
public List<FactProforma> getFactProformaList() {
    return factProformaList;
}

public void setFactProformaList(List<FactProforma> factProformaList) {
    this.factProformaList = factProformaList;
}

@XmlTransient
public List<Bl> getBlList() {
    return blList;
}

public void setBlList(List<Bl> blList) {
    this.blList = blList;
}

@Override
public int hashCode() {
    int hash = 0;
    hash += (idclient != null ? idclient.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 Client)) {
        return false;
    }
    Client other = (Client) object;
    if ((this.idclient == null && other.idclient != null) || (this.idclient != null && !this.idclient.equals(other.idclient))) {
        return false;
    }
    return true;
}

@Override
public String toString() {
    return "glob.entitys.Client[ idclient=" + idclient + " ]";
  }

}

when I try to insert a row into the data base :

Utilisateur user=new Utilisateur(loginActuel);
Client client=new Client(0);// the error comes from here
Facture fact=new Facture(null,new Date());
fact.setClientIdclient(client);
fact.setUtilisateurLogin(user);
FactureJpaController fjc=new FactureJpaController(emf);
fjc.create(fact);

I get this ugly error(but when i set new Client(1) it works well):

Exception in thread "AWT-EventQueue-0" javax.persistence.RollbackException: Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ValidationException

Exception Description: Null or zero primary key encountered in unit of work clone [glob.entitys.Client[ idclient=0 ]], primary key [0]. Set descriptors IdValidation or the "eclipselink.id-validation" property.

how to solve this problem ?

remark: the client idclient = 0 is already inserted in the Database(but manually)
I’d like once and for all overcome this “problem” , how to prevent JPA or H2 Database to start from 0 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:34:41+00:00Added an answer on May 31, 2026 at 10:34 am

    H2 does allow to use 0 as the primary key. The error message doesn’t come from H2.

    However, it seems to me that some (older?) version of EclipseLink doesn’t allow to use 0.

    the client idclient = 0 is already inserted in the Database

    It seems this is not supported by this version of EclipseLink. It looks like to work around this problem, you should not use the value 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following tables in a database (i'll only list the important attributes):
I have the following tables CREATE TABLE `files` ( `fileid` int(11) NOT NULL AUTO_INCREMENT,
I have the following tables represented in my Entity Framework diagram (.edmx file) Users
I have following tables questions -> id, question_data, user_id users -> id, fname, lname
I have the following tables. I wanted it so when I make more boxes
I have the following tables in SQL Server 2005 ReceiptPoint: ID (PK), Name GasIndexLocation:
i have the following tables in sql server: photoalbumsTable: album_ID album_caption albumtagmap id album_id
I have the following tables, with these keys in my database: bookings session_id sessions
I have the following tables: CREATE TABLE title ( booktitle VARCHAR( 60 ), title_id
I have the following Tables: Players id playerName Weapons id type otherData Weapons2Player id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.