Optimalizováno načítání požadavků z databáze. Položky požadavků se

načítají jako lazy.
Verze_1.0
Josef Rokos 10 years ago
parent 412db2a394
commit 3725e9473d

@ -16,7 +16,7 @@ import javax.persistence.Table;
@Table(name = "REQUIREMENT")
public class Requirement extends RequirementBase
{
@OneToMany(fetch = FetchType.EAGER, mappedBy = "requirement", cascade = CascadeType.ALL, orphanRemoval = true)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "requirement", cascade = CascadeType.ALL, orphanRemoval = true)
private List<RequirementItem> items;
@Column(name = "DELIVERYDATE")

@ -9,6 +9,8 @@ import java.util.List;
public interface RequirementService extends RequirementBaseService<Requirement>
{
public void loadGroups(Requirement req);
public void loadItems(Requirement req);
public BigDecimal calcTotalFromItem(RequirementItem item);

@ -14,6 +14,7 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.hibernate.Hibernate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@ -135,6 +136,19 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
// materiálů a služeb konzistentní
req.setItems(items);
}
@Override
@Transactional
@LazyLoader("form")
public void loadItems(Requirement req) {
if (req == null) {
return;
}
Requirement r = getById(req.getId());
Hibernate.initialize(r.getItems());
req.setItems(r.getItems());
}
@Override
public BigDecimal calcTotalFromItem(RequirementItem item)

Loading…
Cancel
Save