diff options
Diffstat (limited to 'proxy/code/src/org/fedoraproject/candlepin/model/Consumer.java')
-rw-r--r-- | proxy/code/src/org/fedoraproject/candlepin/model/Consumer.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/proxy/code/src/org/fedoraproject/candlepin/model/Consumer.java b/proxy/code/src/org/fedoraproject/candlepin/model/Consumer.java index 83f3670..6bc0019 100644 --- a/proxy/code/src/org/fedoraproject/candlepin/model/Consumer.java +++ b/proxy/code/src/org/fedoraproject/candlepin/model/Consumer.java @@ -36,6 +36,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; +import org.hibernate.annotations.ForeignKey; /** * A Consumer is the entity that uses a given Entitlement. It can be a user, @@ -60,9 +61,12 @@ public class Consumer { @ManyToOne @JoinColumn(nullable=false) + @ForeignKey(name="fk_consumer_consumer_type") private ConsumerType type; @ManyToOne + @ForeignKey(name="fk_consumer_owner") + @JoinColumn(nullable=false) private Owner owner; // Consumer hierarchy it meant to be useful to represent the relationship between @@ -73,15 +77,20 @@ public class Consumer { inverseJoinColumns=@JoinColumn(name="CHILD_CONSUMER_ID")) private Set<Consumer> childConsumers; + // Separate mapping because in theory, a consumer could be consuming products they're // not entitled to. @ManyToMany + @ForeignKey(name="fk_consumer_product_consumer_id", + inverseName="fk_consumer_product_product_id") @JoinTable(name="cp_consumer_products", joinColumns=@JoinColumn(name="consumer_id"), inverseJoinColumns=@JoinColumn(name="product_id")) private Set<Product> consumedProducts; @OneToMany + @ForeignKey(name="fk_consumer_product_consumer_id", + inverseName="fk_consumer_produce_product_id") @JoinTable(name="cp_consumer_entitlements", joinColumns=@JoinColumn(name="consumer_id"), inverseJoinColumns=@JoinColumn(name="entitlement_id")) @@ -96,16 +105,14 @@ public class Consumer { this.owner = owner; this.type = type; - this.info = new ConsumerInfo(); - this.info.setConsumer(this); // TODO: ??? + this.info = new ConsumerInfo(this); this.childConsumers = new HashSet<Consumer>(); this.consumedProducts = new HashSet<Product>(); this.entitlements = new HashSet<Entitlement>(); } public Consumer() { - this.info = new ConsumerInfo(); - this.info.setConsumer(this); // TODO: ??? + this.info = new ConsumerInfo(this); this.childConsumers = new HashSet<Consumer>(); this.consumedProducts = new HashSet<Product>(); this.entitlements = new HashSet<Entitlement>(); |