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

View File

@ -34,7 +34,7 @@ public class PacComponent implements Serializable {
@ManyToOne @ManyToOne
@JoinColumn(name = "basecomponent_id") @JoinColumn(name = "basecomponent_id")
private Component component; private BaseComponent baseComponent;
@Column(name = "quantity", columnDefinition = "integer") @Column(name = "quantity", columnDefinition = "integer")
private int quantity; private int quantity;
@ -52,7 +52,11 @@ public class PacComponent implements Serializable {
} }
public BaseComponent getBaseComponent() { public BaseComponent getBaseComponent() {
return getComponent().getBaseComponent(); return baseComponent;
}
public void setBaseComponent(BaseComponent baseComponent) {
this.baseComponent = baseComponent;
} }
public Pac getPac() { public Pac getPac() {
@ -87,17 +91,9 @@ public class PacComponent implements Serializable {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
public Component getComponent() {
return component;
}
public void setComponent(Component component) {
this.component = component;
}
@Override @Override
public String toString() { 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; Component comp = (Component) cObj;
PacComponent pacComponent = new PacComponent(); PacComponent pacComponent = new PacComponent();
BaseComponent baseComponent = comp.getBaseComponent(); BaseComponent baseComponent = comp.getBaseComponent();
pacComponent.setComponent(comp); pacComponent.setBaseComponent(comp.getBaseComponent());
pacComponent.setCreated(now); pacComponent.setCreated(now);
pacComponent.setPac(pac); pacComponent.setPac(pac);
String feature = baseComponent.getFeature(); String feature = baseComponent.getFeature();