found one more mapping error with migrated database

This commit is contained in:
Peter Hormanns 2013-05-23 15:30:26 +02:00
parent d305c64646
commit 71bd2b5ad3
3 changed files with 11 additions and 15 deletions

View File

@ -49,7 +49,7 @@ public class Pac extends AbstractEntity implements Serializable {
private String name;
@JoinColumn(name = "bp_id")
@ManyToOne(fetch = EAGER)
@ManyToOne(fetch = LAZY)
private Customer customer;
@JoinColumn(name = "basepacket_id")
@ -79,7 +79,7 @@ public class Pac extends AbstractEntity implements Serializable {
@ManyToOne(fetch = EAGER)
private INetAddress oldINetAddr;
@OneToMany(fetch = EAGER, cascade = ALL, mappedBy="pac")
@OneToMany(fetch = EAGER, cascade = ALL, mappedBy="pac", orphanRemoval=true)
private Set<PacComponent> pacComponents;
@OneToMany(fetch = LAZY, cascade = ALL, mappedBy="pac")
@ -95,7 +95,7 @@ public class Pac extends AbstractEntity implements Serializable {
for (Component comp : basePac.getComponents()) {
PacComponent pacComp = new PacComponent();
pacComp.setCreated(today);
pacComp.setComponent(comp);
pacComp.setBaseComponent(comp.getBaseComponent());
pacComp.setPac(this);
if (setDefaults) {
pacComp.setQuantity(comp.getDefaultQuantity());

View File

@ -34,7 +34,7 @@ public class PacComponent implements Serializable {
@ManyToOne
@JoinColumn(name = "basecomponent_id")
private Component component;
private BaseComponent baseComponent;
@Column(name = "quantity", columnDefinition = "integer")
private int quantity;
@ -52,7 +52,11 @@ public class PacComponent implements Serializable {
}
public BaseComponent getBaseComponent() {
return getComponent().getBaseComponent();
return baseComponent;
}
public void setBaseComponent(BaseComponent baseComponent) {
this.baseComponent = baseComponent;
}
public Pac getPac() {
@ -87,17 +91,9 @@ public class PacComponent implements Serializable {
this.cancelled = cancelled;
}
public Component getComponent() {
return component;
}
public void setComponent(Component component) {
this.component = component;
}
@Override
public String toString() {
return "pac=" + pac.getName() + ";comp=" + component.getBaseComponent().getFeature() + ";quantity=" + getQuantity();
return "pac=" + pac.getName() + ";comp=" + getBaseComponent().getFeature() + ";quantity=" + getQuantity();
}
}

View File

@ -80,7 +80,7 @@ public class PacModuleImpl extends AbstractModuleImpl {
Component comp = (Component) cObj;
PacComponent pacComponent = new PacComponent();
BaseComponent baseComponent = comp.getBaseComponent();
pacComponent.setComponent(comp);
pacComponent.setBaseComponent(comp.getBaseComponent());
pacComponent.setCreated(now);
pacComponent.setPac(pac);
String feature = baseComponent.getFeature();