私はこのクラスにマップされたテーブルを持っています:
@Entity(name = "status_history")
@Table
public class StatusChange implements Comparable<StatusChange> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name = "when_")
@Temporal(TemporalType.TIMESTAMP)
private Date when;
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "ordering_id")
private Ordering ordering;
private Short status;
...
@Override
public int hashCode() {
return id.intValue();
}
@Override
public boolean equals(Object o) {
if (o instanceof StatusChange) {
StatusChange sc = (StatusChange) o;
if (id == null) {
return false;
}
return id.equals(sc.getId());
}
return false;
}
...
5006行あります。このクエリを実行すると、ログが表示される理由:
Query query = em.createQuery("SELECT DISTINCT sh FROM status_history sh");
return query.getResultList();
ロギングは、JPA が関連付けられたクラスも取得していることを示しています。
[EL Fine]: sql: 2013-08-09 17:02:52.631--ServerSession(27039955)--Connection(12972016)--Thread(Thread[main,5,main])--SELECT ID, TYPE, anniversary_newspapers, anniversary_newspapers_type, AUTHOR, copy_color, copy_format, decorated_folder, decorated_folder_note, delivery_type, publishing_description, SIGNATURE, TITLE, USAGE, work_amount, work_amount_desc, work_type, year_, BARCODE, comment_, denial_reason, EXHIBITION, exhibition_name, further_processing, LZA, no_new_scans, ONLINE, RESTORATION, SMALL, URGENT FROM ordered_object WHERE (ID = ?)
bind => [54]
[EL Fine]: sql: 2013-08-09 17:02:52.632--ServerSession(27039955)--Connection(12972016)--Thread(Thread[main,5,main])--SELECT ID, TYPE, cancel_comment, claim_comment, COMMUNICATION, EDITOR, internal_id, LOCATION, STATUS, YEAR, yearly_number, billing_contact_id, oo_id, orderer_id, accumulated, customer_created, estimated_price, no_barcode, no_object, accumulated_id FROM ORDERING WHERE (oo_id = ?)
bind => [54]
[EL Fine]: sql: 2013-08-09 17:02:52.634--ServerSession(27039955)--Connection(12972016)--Thread(Thread[main,5,main])--SELECT ID, _comment, control_finished, CONTROLLER, date_of_entry, empty_pages, scan_finished, scan_method1, scan_method2, scan_operator, SCANNER, SENDER, thumbnail_number, total_pages, oo_id FROM SCAN_INFO WHERE (oo_id = ?)
bind => [54]
[EL Fine]: sql: 2013-08-09 17:02:52.635--ServerSession(27039955)--Connection(12972016)--Thread(Thread[main,5,main])--SELECT ID, onb_employee, contact_id FROM ORDERER WHERE (ID = ?)
bind => [54]
クエリには 30 秒かかります。ここで何が欠けていますか?事前にどうもありがとう!