Good morning every one, I have got some troubles here with my JPA project.
I have three entities and an abstract class which implements an interface.
Here is the code :
Application.java
package com.bfi.webtop.model;
/***********************************************************************
* Module: Application.java
* Author: Marwa
* Purpose: Defines the Class Application
***********************************************************************/
import java.io.Serializable;
import java.util.*;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import javax.persistence.Table;
/** @pdOid d477195f-149e-4336-8586-19d6a09ee2d4 */
@Entity
@Table(name="application_")
public class Application implements FileSystemElement, Serializable {
public Application() {
super();
}
public Application(Long id_app, String url) {
super();
this.id_app = id_app;
this.url = url;
}
private Long id_app;
private java.lang.String url;
/**
* @return the url
*/
public java.lang.String getUrl() {
return url;
}
/**
* @param url the url to set
*/
public void setUrl(java.lang.String url) {
this.url = url;
}
/**
* @return the id_app
*/
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long getId_app() {
return id_app;
}
/**
* @param id_app the id_app to set
*/
public void setId_app(Long id_app) {
this.id_app = id_app;
}
@Override
public String getChemin() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setChemin(String chemin) {
// TODO Auto-generated method stub
}
@Override
public String getNom() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setNom(String nom) {
// TODO Auto-generated method stub
}
@Override
public Long getTaille() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setTaille(Long taille) {
// TODO Auto-generated method stub
}
@Override
public Date getDateDerniereModification() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setDateDerniereModification(Date dateDerniereModification) {
// TODO Auto-generated method stub
}
@Override
public Date getDateCreation() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setDateCreation(Date dateCreation) {
// TODO Auto-generated method stub
}
@Override
public String getIcone() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setIcone(String icone) {
// TODO Auto-generated method stub
}
@Override
public String getDescription() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setDescription(String description) {
// TODO Auto-generated method stub
}
@Override
public String getVersion() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setVersion(String version) {
// TODO Auto-generated method stub
}
@Override
public Boolean getPartage() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setPartage(Boolean partage) {
// TODO Auto-generated method stub
}
@Override
public Utilisateur getOwner() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setOwner(Utilisateur owner) {
// TODO Auto-generated method stub
}
@Override
public ConteneurElement getParent() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setParent(ConteneurElement parent) {
// TODO Auto-generated method stub
}
@Override
public void setSousElements(Collection<Repertoire> sousElements) {
// TODO Auto-generated method stub
}
}
Fichier.java
package com.bfi.webtop.model;
/***********************************************************************
* Module: Fichier.java
* Author: Marwa
* Purpose: Defines the Class Fichier
***********************************************************************/
import java.util.*;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class Fichier implements FileSystemElement {
private Long id_fichier;
private java.lang.String extension;
private java.lang.Boolean supprim;
/**
* @return the extension
*/
public java.lang.String getExtension() {
return extension;
}
/**
* @param extension the extension to set
*/
public void setExtension(java.lang.String extension) {
this.extension = extension;
}
/**
* @return the supprim
*/
public java.lang.Boolean getSupprim() {
return supprim;
}
/**
* @param supprim the supprim to set
*/
public void setSupprim(java.lang.Boolean supprim) {
this.supprim = supprim;
}
/**
* @return the id_fichier
*/
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long getId_fichier() {
return id_fichier;
}
/**
* @param id_fichier the id_fichier to set
*/
public void setId_fichier(Long id_fichier) {
this.id_fichier = id_fichier;
}
public Fichier() {
}
}
Raccourci.java
package com.bfi.webtop.model;
/***********************************************************************
*
* Module: Raccourci.java
* Author: Marwa
* Purpose: Defines the Class Raccourci
***********************************************************************/
import java.io.Serializable;
import java.util.*;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
/** @pdOid 64bd8bf2-e4dd-4dab-b0c9-18156b9ead9a */
@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class Raccourci implements FileSystemElement, Serializable {
private Long id_rac;
/**
* @return the id_rac
*/
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long getId_rac() {
return id_rac;
}
/**
* @param id_rac the id_rac to set
*/
public void setId_rac(Long id_rac) {
this.id_rac = id_rac;
}
private java.lang.String alias;
public java.lang.String getAlias() {
return alias;
}
/**
* @param alias the alias to set
*/
public void setAlias(java.lang.String alias) {
this.alias = alias;
}
public Raccourci() {
super();
}
}
ConteneurElement.java
package com.bfi.webtop.model;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/***********************************************************************
*
*
*
* Module: ConteneurElement.java Author: Marwa Purpose: Defines the Class
* ConteneurElement
***********************************************************************/
@Entity
@Table(name = "CONTENEUR_ELEM")
@MappedSuperclass
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="TYPE_")
public abstract class ConteneurElement implements FileSystemElement {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID_CONTENEUR")
private Long id;
@Column(name="TYPE_")
private String type;
@Column(name = "CHEMIN_", nullable = false)
private String chemin;
@Column(name = "NOM_", nullable = false)
private String nom;
@Column(name = "TAILLE_", nullable = false)
private Long taille;
@Column(name = "DATE_MODIFICATION", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date dateDerniereModification;
@Column(name = "DATE_CREATION", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date dateCreation;
@Column(name = "ICONE_")
private String icone;
@Column(name = "DESCRIPTION_")
private String description;
@Column(name = "NUM_VERSION_")
private String version;
@Column(name = "EST_PARTAGE")
private Boolean partage = false;
@ManyToOne(optional=false)
@JoinColumn(name="OWNERPK_",referencedColumnName="ID_USER_")
private Utilisateur owner;
@ManyToOne(optional=true)
@JoinColumn(name="PARENTPK_",referencedColumnName="ID_CONTENEUR")
private ConteneurElement parent;
/**
* @return the parent
*/
public ConteneurElement getParent() {
return parent;
}
/**
* @param parent the parent to set
*/
public void setParent(ConteneurElement parent) {
this.parent = parent;
}
/**
* @return the chemin
*/
public String getChemin() {
return chemin;
}
/**
* @param chemin
* the chemin to set
*/
public void setChemin(String chemin) {
this.chemin = chemin;
}
/**
* @return the nom
*/
public String getNom() {
return nom;
}
/**
* @param nom
* the nom to set
*/
public void setNom(String nom) {
this.nom = nom;
}
/**
* @return the taille
*/
public Long getTaille() {
return taille;
}
/**
* @param taille
* the taille to set
*/
public void setTaille(Long taille) {
this.taille = taille;
}
/**
* @return the dateDerniereModification
*/
public Date getDateDerniereModification() {
return dateDerniereModification;
}
/**
* @param dateDerniereModification
* the dateDerniereModification to set
*/
public void setDateDerniereModification(
Date dateDerniereModification) {
this.dateDerniereModification = dateDerniereModification;
}
/**
* @return the dateCreation
*/
public Date getDateCreation() {
return dateCreation;
}
/**
* @param dateCreation
* the dateCreation to set
*/
public void setDateCreation(Date dateCreation) {
this.dateCreation = dateCreation;
}
/**
* @return the icone
*/
public String getIcone() {
return icone;
}
/**
* @param icone
* the icone to set
*/
public void setIcone(String icone) {
this.icone = icone;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the version
*/
public String getVersion() {
return version;
}
/**
* @param version
* the version to set
*/
public void setVersion(String version) {
this.version = version;
}
/**
* @return the partage
*/
public Boolean getPartage() {
return partage;
}
/**
* @param partage
* the partage to set
*/
public void setPartage(Boolean partage) {
this.partage = partage;
}
public abstract void ajouterFils(FileSystemElement element);
public abstract void supprimerFils(FileSystemElement element);
public abstract Collection<FileSystemElement> getSousElements();
public abstract Iterator<FileSystemElement> getIteratorSousElements();
/**
* @param newSousElements
*/
public void setSousElements(
Collection<FileSystemElement> newSousElements) {
removeAllSousElements();
for (Iterator<FileSystemElement> iter = newSousElements.iterator(); iter
.hasNext();)
addSousElements((FileSystemElement) iter.next());
}
/**
* @param newFileSystemElement
*/
public abstract void addSousElements(FileSystemElement newFileSystemElement);
/**
* @param oldFileSystemElement
*/
public abstract void removeSousElements(
FileSystemElement oldFileSystemElement);
public void removeAllSousElements() {
if (getSousElements() != null)
getSousElements().clear();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Utilisateur getOwner() {
return owner;
}
public void setOwner(Utilisateur owner) {
this.owner = owner;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
and finally The interface
FileSystemElement.java
package com.bfi.webtop.model;
import java.util.Collection;
import java.util.Date;
import javax.annotation.Generated;
import javax.persistence.Entity;
import javax.persistence.PersistenceUnit;
import javax.persistence.Table;
/***********************************************************************
* Module: FileSystemElement.java
* Author: Marwa
* Purpose: Defines the Interface FileSystemElement
***********************************************************************/
public interface FileSystemElement {
String getChemin();
void setChemin(String chemin);
String getNom();
void setNom(String nom);
Long getTaille();
void setTaille(Long taille);
Date getDateDerniereModification();
void setDateDerniereModification(Date dateDerniereModification);
Date getDateCreation();
void setDateCreation(Date dateCreation);
String getIcone();
void setIcone(String icone);
String getDescription();
void setDescription(String description);
String getVersion();
void setVersion(String version);
Boolean getPartage();
void setPartage(Boolean partage);
Utilisateur getOwner();
void setOwner(Utilisateur owner);
ConteneurElement getParent();
void setParent(ConteneurElement parent);
void setSousElements(Collection<Repertoire> sousElements);
}
I am using a mysql database.
When I try to generate tables from entities I got those exceptions :
Quote:Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: org.eclipse.persistence.dynamic.DynamicClassLoader@406199
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [webtop] failed.
Internal Exception: java.util.NoSuchElementException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:115)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:75)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:63)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [webtop] failed.
Internal Exception: java.util.NoSuchElementException
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1541)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1532)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:105)
... 3 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [webtop] failed.
Internal Exception: java.util.NoSuchElementException
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:221)
... 7 more
Caused by: java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(Unknown Source)
at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.getPrimaryKeyField(MetadataDescriptor.java:991)
at org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor.getReferencedField(MetadataAccessor.java:432)
at org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor.getReferencedField(MetadataAccessor.java:420)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.addMultipleTableKeyFields(EntityAccessor.java:201)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processInheritancePrimaryKeyJoinColumns(EntityAccessor.java:1007)
at org.eclipse.persistence.internal.jpa.metadata.inheritance.InheritanceMetadata.processInheritanceRoot(InheritanceMetadata.java:265)
at org.eclipse.persistence.internal.jpa.metadata.inheritance.InheritanceMetadata.process(InheritanceMetadata.java:230)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processInheritance(EntityAccessor.java:980)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processTableAndInheritance(EntityAccessor.java:1205)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:619)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1686)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:532)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:550)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1469)
... 5 more
Any help