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")

@ -10,6 +10,8 @@ public interface RequirementService extends RequirementBaseService<Requirement>
{
public void loadGroups(Requirement req);
public void loadItems(Requirement req);
public BigDecimal calcTotalFromItem(RequirementItem item);
public RequirementItem calcTotalInItem(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;
@ -136,6 +137,19 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
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