Die Fehlermeldung lautet
Exception in thread „main“ Local Exception Stack:
Exception [EclipseLink-6076] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Object comparisons can only be used with OneToOneMappings. Other mapping comparisons must be done through query keys or direct attribute level comparisons.
Mapping: [org.eclipse.persistence.mappings.DirectToFieldMapping[id–>language.ID]]
Expression: [
Query Key id
Base roy.entities.localisation.Language]
Query: ReportQuery(referenceClass=Language jpql=„SELECT l.iso639, l.flag, n.name FROM Language l LEFT JOIN LanguageName n ON l.id = n.owner WHERE l.published = 1 AND l.deletedAt IS NULL AND n.language = :language“)
at org.eclipse.persistence.exceptions.QueryException.unsupportedMappingForObjectComparison(QueryException.java:1170)
at org.eclipse.persistence.mappings.DatabaseMapping.buildObjectJoinExpression(DatabaseMapping.java:292)
at org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:832)
at org.eclipse.persistence.expressions.ExpressionBuilder.normalize(ExpressionBuilder.java:267)
at org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:825)
at org.eclipse.persistence.internal.expressions.CompoundExpression.normalize(CompoundExpression.java:232)
at org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1449)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildReportQuerySelectStatement(ExpressionQueryMechanism.java:641)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildReportQuerySelectStatement(ExpressionQueryMechanism.java:586)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareReportQuerySelectAllRows(ExpressionQueryMechanism.java:1694)
at org.eclipse.persistence.queries.ReportQuery.prepareSelectAllRows(ReportQuery.java:1203)
at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:744)
at org.eclipse.persistence.queries.ReportQuery.prepare(ReportQuery.java:1071)
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:661)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:901)
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:194)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:116)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.(EJBQueryImpl.java:102)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.(EJBQueryImpl.java:86)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1603)
at roy.main.Main.main(Main.java:33)
Hier auch nochmal die beiden Entitäten
@Entity
@Table(name="language_name")
public class LanguageName implements IEntity<Integer> {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(nullable = false)
private Integer id;
@JoinColumn(name = "owner_id", referencedColumnName = "id")
@ManyToOne(optional = false)
private Language owner;
@JoinColumn(name = "language_id", referencedColumnName = "id")
@ManyToOne(optional = false)
private Language language;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 255)
@Column(name = "name")
private String name;
public LanguageName() {
}
public LanguageName(Integer id) {
this.id = id;
}
@Override
public Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Language getOwner() {
return owner;
}
public void setOwner(Language owner) {
this.owner = owner;
}
public Language getLanguage() {
return language;
}
public void setLanguage(Language language) {
this.language = language;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.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 LanguageName)) {
return false;
}
LanguageName other = (LanguageName) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "LanguageName[ id=" + id + " ]";
}
}
@Entity
@Table(name="language")
@NamedQueries({
@NamedQuery(name = "Language.availabels", query = "SELECT l FROM Language l WHERE l.published = true AND l.deletedAt IS NULL")
})
public class Language implements IMaintainceEntity<Integer> {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(nullable = false)
private Integer id;
@Column(name = "created_at")
@Temporal(TemporalType.TIMESTAMP)
private Date createdAt;
@JoinColumn(name = "created_by", referencedColumnName = "id")
@ManyToOne(fetch = FetchType.LAZY)
private Person createdBy;
@Column(name = "modified_at")
@Temporal(TemporalType.TIMESTAMP)
private Date modifiedAt;
@JoinColumn(name = "modified_by", referencedColumnName = "id")
@ManyToOne(fetch = FetchType.LAZY)
private Person modifiedBy;
@Column(name = "deleted_at")
@Temporal(TemporalType.TIMESTAMP)
private Date deletedAt;
@JoinColumn(name = "deleted_by", referencedColumnName = "id")
@ManyToOne(fetch = FetchType.LAZY)
private Person deletedBy;
@Basic(optional = false)
@NotNull
@Column(nullable = false)
private boolean published;
private Integer ordering;
@Basic(optional = false)
@NotNull
@Column(nullable = false)
private boolean standard;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 10)
@Column(nullable = false, length = 10)
private String iso639;
@Size(max = 255)
@Column(length = 255)
private String flag;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 255)
@Column(name = "short_date_format", nullable = false, length = 255)
private String shortDateFormat;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 255)
@Column(name = "long_date_format", nullable = false, length = 255)
private String longDateFormat;
@OneToMany(mappedBy = "preferedLanguage", fetch = FetchType.LAZY)
private List<Person> personList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner", fetch = FetchType.LAZY)
private List<LanguageName> languageNames;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "language", fetch = FetchType.LAZY)
private List<LanguageName> usingLanguages;
public Language() {
}
public Language(Integer id) {
this.id = id;
}
@Override
public Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
this.id = id;
}
@Override
public Date getCreatedAt() {
return createdAt;
}
@Override
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
@Override
public Person getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(Person createdBy) {
this.createdBy = createdBy;
}
@Override
public Date getModifiedAt() {
return modifiedAt;
}
@Override
public void setModifiedAt(Date modifiedAt) {
this.modifiedAt = modifiedAt;
}
@Override
public Person getModifiedBy() {
return modifiedBy;
}
@Override
public void setModifiedBy(Person modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Date getDeletedAt() {
return deletedAt;
}
public void setDeletedAt(Date deletedAt) {
this.deletedAt = deletedAt;
}
public Person getDeletedBy() {
return deletedBy;
}
public void setDeletedBy(Person deletedBy) {
this.deletedBy = deletedBy;
}
public boolean isPublished() {
return published;
}
public void setPublished(boolean published) {
this.published = published;
}
public Integer getOrdering() {
return ordering;
}
public void setOrdering(Integer ordering) {
this.ordering = ordering;
}
public boolean isStandard() {
return standard;
}
public void setStandard(boolean standard) {
this.standard = standard;
}
public String getIso639() {
return iso639;
}
public void setIso639(String iso639) {
this.iso639 = iso639;
}
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
public String getShortDateFormat() {
return shortDateFormat;
}
public void setShortDateFormat(String shortDateFormat) {
this.shortDateFormat = shortDateFormat;
}
public String getLongDateFormat() {
return longDateFormat;
}
public void setLongDateFormat(String longDateFormat) {
this.longDateFormat = longDateFormat;
}
public List<Person> getPersonList() {
return personList;
}
public void setPersonList(List<Person> personList) {
this.personList = personList;
}
public List<LanguageName> getLanguageNames() {
return languageNames;
}
public void setLanguageNames(List<LanguageName> languageNames) {
this.languageNames = languageNames;
}
public List<LanguageName> getUsingLanguages() {
return usingLanguages;
}
public void setUsingLanguages(List<LanguageName> usingLanguages) {
this.usingLanguages = usingLanguages;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.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 Language)) {
return false;
}
Language other = (Language) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "Language{" + "id=" + id + ", createdAt=" + createdAt + ", createdBy=" + createdBy + ", modifiedAt=" + modifiedAt + ", modifiedBy=" + modifiedBy + ", deletedAt=" + deletedAt + ", deletedBy=" + deletedBy + ", published=" + published + ", ordering=" + ordering + ", standard=" + standard + ", iso639=" + iso639 + ", flag=" + flag + ", shortDateFormat=" + shortDateFormat + ", longDateFormat=" + longDateFormat + ", personList=" + personList + ", languageNames=" + languageNames + ", usingLanguages=" + usingLanguages + '}';
}
}