我正在使用基于Spring的java Web应用程序。为了访问数据库,我使用Spring Data 1.11.6.RELEASE和Hibernate 5.2。我的数据库是MySQL 5.7
涉及的实体是 - 具有一些共同字段的BaseEntity
@MappedSuperclass
public abstract class BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@ManyToOne
@CreatedBy
private WebUser createdBy;
...
...
}
广告
@Entity
@Table(name = "advertising")
public class Advertising extends BaseEntity {
@ManyToOne
private AdvertisingStatus status;
...
...
}
最后是WebUser
@Entity
@Table(name = "web_user",uniqueConstraints = @UniqueConstraint(columnNames = {"mail"}))
public class WebUser extends BaseEntity {
@ManyToOne
private WebUserStatus webUserStatus;
...
...
我不明白为什么从这个HQL和具有maxRows = 75
的Pageable对象开始from Advertising a
where a.status in (:adStatuses)
and a.createdBy.webUserStatus.id = :webUserStatus
order by orderDate desc
生成的查询如下
select *
from advertising advertisin0_
cross join web_user webuser1_ where advertisin0_.createdBy_id=webuser1_.id
and (advertisin0_.status_id in (1 , 9))
and webuser1_.webUserStatus_id=1
order by advertisin0_.orderDate desc limit 75
我关心的是交叉连接,它应该比标准连接慢。 是否可以进行标准连接而不是交叉连接?