我有一个使用带有Schema
鉴别符的多租户系统,并使用EclipseLink 2.7.3。正是为了避免这个(Bug 493235)(和其他)错误,我才移至EclipseLink 2.7.3。但是,出现以下异常:
java.lang.IllegalArgumentException: Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.7.3.v20180807-4be1041): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [`database_1`.library.libId] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="Library.findByReservationId" referenceClass=Library jpql="SELECT l FROM Library l WHERE l.libId = (SELECT r.lib.libId FROM Reservation r WHERE r.reservId = :reservId)")
我的实体看起来像这样:
@Entity
@Multitenant(value = TABLE_PER_TENANT)
@TenantTableDiscriminator(type = SCHEMA, contextProperty = MULTITENANT_PROPERTY_DEFAULT)
@Table(name = "library")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Library.findByReservId", query = "SELECT l FROM Library l WHERE l.libId = (SELECT r.lib.libId FROM Reservation r WHERE r.reservId = :reservId)")})
public class Library implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "libId")
private Long libId;
...
@OneToMany(cascade = CascadeType.ALL, mappedBy = "libId")
private List<Reservation> reservList;
...
}
@Entity
@Multitenant(value = TABLE_PER_TENANT)
@TenantTableDiscriminator(type = SCHEMA, contextProperty = MULTITENANT_PROPERTY_DEFAULT)
@Table(name = "reservation")
@XmlRootElement
public class Reservation implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "reservId")
private Long reservId;
@JoinColumn(name = "lib", referencedColumnName = "libId")
@ManyToOne(optional = false)
private Library lib;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "reservation")
private List<BookReservation> bookReservationList;
@Transient
private List<Long> bookIdList;
...
}
该错误应该在2.7版中消失了。我错了吗?这里还会有其他事情吗?这个错误还会困扰EclipseLink 2.7.3吗? 谢谢您的回答。