1
我使用EclipseLink作爲我的JPA提供程序。我的應用程序工作正常,但最近在部署應用程序時它給我一個錯誤,並且它不再工作。我是JPA的新手,儘管我已經閱讀了日誌,但我無法理解發生了什麼。這與EclipseLink-93和EclipseLink-41異常有關。有人能幫助我嗎?先謝謝你。無法預先部署PersistenceUnit [PU]處於無效狀態[DeployFailed]
Exception [EclipseLink-93] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The table [CONTACT] is not present in this descriptor.
Descriptor: RelationalDescriptor(science.softdev.SongPromoter.model.Album --> [DatabaseTable(ALBUM)])
Exception [EclipseLink-41] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A non-read-only mapping must be defined for the sequence number field.
Descriptor: RelationalDescriptor(science.softdev.SongPromoter.model.Album -- [DatabaseTable(ALBUM)])
Runtime Exceptions:
---------------------------------------------------------
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1656)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:130)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:188)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at science.softdev.SongPromoter.Persistance.<clinit>(Persistance.java:16)
... 67 more
Caused by: Exception [EclipseLink-28017] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Unable to predeploy PersistenceUnit [PU] in invalid state [DeployFailed].
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [PU] failed. Close all factories for this PersistenceUnit.
Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.IntegrityException
這是我的專輯和聯繫類的代碼:
package science.softdev.SongPromoter.model;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Entity
public class Album {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idAlbum;
private String albumUUID = UUID.randomUUID().toString();
private String name;
private String author;
private boolean active = true;
private String simplifiedDate;
private String zipUUID = UUID.randomUUID().toString();
private String description = "";
public int getIdAlbum() {
return idAlbum;
}
public void setIdAlbum(int idAlbum) {
this.idAlbum = idAlbum;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getZipUUID() {
return zipUUID;
}
public void setZipUUID(String zipUUID) {
this.zipUUID = zipUUID;
}
public String getSimplifiedDate() {
return simplifiedDate;
}
public void setSimplifiedDate(String simplifiedDate) {
this.simplifiedDate = simplifiedDate;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public void setAlbumUUID(String albumUUID) {
this.albumUUID = albumUUID;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
private String cover;
private String coverUUID = UUID.randomUUID().toString();
public String getCoverUUID() {
return coverUUID;
}
public void setCoverUUID(String coverUUID) {
this.coverUUID = coverUUID;
}
private String zipLocation;
private Date releaseDate;
public String getAlbumUUID() {
return albumUUID;
}
public String getZipLocation() {
return zipLocation;
}
public void setZipLocation(String zipLocation) {
this.zipLocation = zipLocation;
}
public Date getReleaseDate() {
return releaseDate;
}
public void setReleaseDate(Date releaseDate) {
this.releaseDate = releaseDate;
}
public String getCover() {
return cover;
}
public void setCover(String cover) {
this.cover = cover;
}
public void setMixes(List<Mix> mixes) {
this.mixes = mixes;
}
@OneToMany(mappedBy="album",cascade = CascadeType.ALL)
private List<Mix> mixes = new ArrayList<Mix>();
@OneToMany(mappedBy="author",cascade = CascadeType.ALL)
private List<Review> reviews = new ArrayList<Review>();
public List<Review> getReviews() {
return reviews;
}
public void setReviews(List<Review> reviews) {
this.reviews = reviews;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Mix> getMixes() {
return mixes;
}
public void setMixes(ArrayList<Mix> mixes) {
this.mixes = mixes;
}
}
這是Contact類:
package science.softdev.SongPromoter.model;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Entity
public class Contact {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idContact;
private String name;
private String email;
private String contactUUID = UUID.randomUUID().toString();
private boolean active;
@OneToMany(mappedBy = "author")
private List<Review> reviews = new ArrayList<Review>();
public List<Review> getReviews() {
return reviews;
}
public void setReviews(List<Review> reviews) {
this.reviews = reviews;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public String getContactUUID() {
return contactUUID;
}
public void setContactUUID(String contactUUID) {
this.contactUUID = contactUUID;
}
public int getIdContact() {
return idContact;
}
public void setIdContact(int id) {
this.idContact = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}