I am using JPA 2 with Eclipselink 2 and Derby in db memory for my tests. When I run my small test program, I get the following exception:
[EL Warning]: 2010-08-12 17: 17: 44.943 - ServerSession (948252856) - Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse. persistence.exceptions.DatabaseException Internal exception: java.sql.SQLSyntaxErrorException: "ALTER TABLE" cannot be thrown in "ARTICLE_ARTICLE" because it does not exist. Error code: 30000 Call: ALTER TABLE ARTICLE_ARTICLE DROP CONSTRAINT RTCLrtclsRltdTTssD Query: DataModifyQuery (sql = "ALTER TABLE ARTICLE_ARTICLE DROP CONSTRAINT RTCLrtclsRltdTTss")
If I try the same with HyperSQL (hsqldb), I get:
[EL Warning]: 2010-08-12 17: 47: 33.179 - ServerSession (1925661675) - Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse. persistence.exceptions.DatabaseException Internal exception: java.sql.SQLException: the user does not have privilege or the object was not found: ARTICLE_ARTICLE Error code: -5501 Call: ALTER TABLE ARTICLE_ARTICLE DROP CONSTRAINT FK_ARTICLE_ARTICLE_ARTLICLE_CRETLE_TRIC_CRETLE_TRIC_TRIC_TRIC_TRIC_TRIC_ATL_TRIC_TRIC_ATL_TRIC_ATL_TRIC_TRIC_ATL_CRETL_STLIC_RATL_STLIC_LOC_STLIC_LOC_LINK_LINK ")
The table generation strategy is drop-and-create, so why does Eclipselink tell me that the table will not exist?
Or is there something wrong with my class class?
@Entity
public class Article implements Serializable {
@Id @GeneratedValue
private int id;
private String title;
@ManyToMany(mappedBy = "relatedArticles")
private Set<Article> articlesRelatedToThis = new HashSet<Article>();
@ManyToMany(cascade = CascadeType.PERSIST)
private Set<Article> relatedArticles = new HashSet<Article>();
public Article() {}
public Article(String title) {
this.title = title;
}
public int getId() {
return id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Set<Article> getRelatedArticles() {
return relatedArticles;
}
public void addRelatedArticle(Article related) {
relatedArticles.add(related);
}
public void removeRelatedArticle(Article related) {
relatedArticles.remove(related);
}
@PreRemove
public void preRemove() {
for(Article article : articlesRelatedToThis)
article.removeRelatedArticle(this);
}
}