我使用名为“ Cuba.Studio ”的框架来创建CRUD应用程序。
当我使用这个JPQL查询时,我得到了这个例外:
Error com.haulmont.cuba.core.global.RemoteException: MetaClass not
found for firstusecase$FIRSTUSECASE_USE_CASE_PROJECT_LINK
这是我的代码:
try (Transaction tx = persistence.createTransaction()) {
EntityManager em = persistence.getEntityManager();
Query query = em.createQuery("select firstusecase$Project.name from
firstusecase$UseCase useCase,
firstusecase$FIRSTUSECASE_USE_CASE_PROJECT_LINK commonTable,
firstusecase$Project project where useCase.id = commonTable.use_case_id
and project.id = commonTable.project_id and useCase.id = :useCaseId")
.setParameter("useCaseId", useCase.getId());
这是我的实体类代码的一部分:
@JoinTable(name = "FIRSTUSECASE_USE_CASE_PROJECT_LINK",
joinColumns = @JoinColumn(name = "USE_CASE_ID"),
inverseJoinColumns = @JoinColumn(name = "PROJECT_ID"))
@ManyToMany
protected Collection<Project> project;
有人有想法吗? 我非常感谢你的支持:)
由于
编辑: 这是UseCase类的代码
package com.company.firstusecase.entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Collection;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import com.haulmont.cuba.core.entity.StandardEntity;
import javax.persistence.Column;
import com.haulmont.chile.core.annotations.NamePattern;
import javax.persistence.Lob;
import com.haulmont.chile.core.annotations.MetaProperty;
import javax.persistence.Transient;
@NamePattern("%s|jamaref")
@Table(name = "FIRSTUSECASE_USE_CASE")
@Entity(name = "firstusecase$UseCase")
public class UseCase extends StandardEntity {
private static final long serialVersionUID = 4928397068727365740L;
@Column(name = "JAMAREF", length = 30)
protected String jamaref;
@Column(name = "PROJECT_LIST")
protected String projectList;
@Transient
@MetaProperty
protected String usecaseDescription;
@Column(name = "CHANGE_TRACKING_COMMENT")
protected String changeTrackingComment;
@Lob
@Column(name = "CHANGE_TRACKING")
protected String changeTracking;
@Column(name = "POWERAMSREF", length = 30)
protected String poweramsref;
@Column(name = "LEGACYPWRUC", length = 30)
protected String legacypwruc;
@Column(name = "TRACKING_CHANGE_COMMENT")
protected String trackingChangeComment;
@Column(name = "INSERT_TIMESTAMP")
protected String insertTimestamp;
@Column(name = "USECASE_TYPE")
protected String usecaseType;
@Column(name = "CHANGE_TIMESTAMP")
protected String changeTimestamp;
@JoinTable(name = "FIRSTUSECASE_USE_CASE_PROJECT_LINK",
joinColumns = @JoinColumn(name = "USE_CASE_ID"),
inverseJoinColumns = @JoinColumn(name = "PROJECT_ID"))
@ManyToMany
protected Collection<Project> project;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "USECASE_STATUS_ID")
protected UseCaseStatus usecaseStatus;
public void setProjectList(String projectList) {
this.projectList = projectList;
}
public String getProjectList() {
return projectList;
}
public String getUsecaseDescription() {
return usecaseDescription;
}
public void setChangeTrackingComment(String changeTrackingComment) {
this.changeTrackingComment = changeTrackingComment;
}
public String getChangeTrackingComment() {
return changeTrackingComment;
}
public void setChangeTracking(String changeTracking) {
this.changeTracking = changeTracking;
}
public void setInsertTimestamp(String insertTimestamp) {
this.insertTimestamp = insertTimestamp;
}
public void setChangeTimestamp(String changeTimestamp) {
this.changeTimestamp = changeTimestamp;
}
public String getInsertTimestamp() {
return insertTimestamp;
}
public void setUsecaseType(String usecaseType) {
this.usecaseType = usecaseType;
}
public String getUsecaseType() {
return usecaseType;
}
public String getChangeTimestamp() {
return changeTimestamp;
}
public String getChangeTracking() {
return changeTracking;
}
public void setTrackingChangeComment(String trackingChangeComment) {
this.trackingChangeComment = trackingChangeComment;
}
public String getTrackingChangeComment() {
return trackingChangeComment;
}
public void setUsecaseStatus(UseCaseStatus usecaseStatus) {
this.usecaseStatus = usecaseStatus;
}
public UseCaseStatus getUsecaseStatus() {
return usecaseStatus;
}
public void setJamaref(String jamaref) {
this.jamaref = jamaref;
}
public String getJamaref() {
return jamaref;
}
public void setPoweramsref(String poweramsref) {
this.poweramsref = poweramsref;
}
public String getPoweramsref() {
return poweramsref;
}
public void setLegacypwruc(String legacypwruc) {
this.legacypwruc = legacypwruc;
}
public String getLegacypwruc() {
return legacypwruc;
}
public void setProject(Collection<Project> project) {
this.project = project;
}
public Collection<Project> getProject() {
return project;
}
}
Project.class的代码
package com.company.firstusecase.entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Column;
import com.haulmont.cuba.core.entity.StandardEntity;
import com.haulmont.chile.core.annotations.NamePattern;
@NamePattern("%s|name")
@Table(name = "FIRSTUSECASE_PROJECT")
@Entity(name = "firstusecase$Project")
public class Project extends StandardEntity {
private static final long serialVersionUID = -3997556855391197754L;
@Column(name = "NAME", nullable = false)
protected String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
由于