I have entity like:
@Entity
@Table(name = "test")
public class TestEntity {
@ElementCollection
@Column(name = "record_type_id", nullable = false)
@CollectionTable(name = "test_entity_record_type", joinColumns = @JoinColumn(name = "test_entity_id"))
private Set<RecordType> recordTypes = new HashSet<>();
@ElementCollection
@Column(name = "record_type_id", nullable = false)
@CollectionTable(name = "test_entity_record_type1", joinColumns = @JoinColumn(name = "test_entity_id"))
private Set<RecordType> recordTypes1 = new HashSet<>();
@ElementCollection
@Column(name = "record_type_id", nullable = false)
@CollectionTable(name = "test_entity_record_type2", joinColumns = @JoinColumn(name = "test_entity_id"))
private Set<RecordType> recordTypes2 = new HashSet<>();
}
I have 1000 records of entity in DB. When i try to get 1000 entityes i see in logs:
- 1000 select to entity table
- 1000 select to test_entity_record_type table by test_entity_id
- 1000 select to test_entity_record_type1 table by test_entity_id
- 1000 select to test_entity_record_type2 table by test_entity_id
As result time of answer is very long.
How can i reduce the response time?