How to access a join table column?!
fabiorusso Jul 24, 2006 1:10 PMHello. I hope this is not a dumb question. I have two Entities with a ManyToMany bidirectional relationship. Up to this point everything is ok. But there is a column in the join table I would like to access and I really don't know how :-(
Here are my Entities: the Partner, the OptionRate and the join table. There is a column named 'isDefault' in the join table that I need to check.
Here is my code:
This is the Partner entity:
@Entity @Table(name="VOW_PARTNERS") public class AbbeyphonePartner implements Serializable { private String partnerId; private String passKey; private String partnerDescription; private List <RateOption> rateOptions; @Id @Column(name="PARTNER_ID") public String getPartnerId() { return this.partnerId; } public void setPartnerId(String partnerId) { this.partnerId = partnerId; } @Column(name="PARTNER_DESCRIPTION") public String getPartnerDescription() { return this.partnerDescription; } public void setPartnerDescription(String partnerDescription) { this.partnerDescription = partnerDescription; } @Column(name="PASS_KEY") public String getPassKey() { return this.passKey; } public void setPassKey(String passKey) { this.passKey = passKey; } @ManyToMany(fetch = FetchType.EAGER , mappedBy ="partners") public List<RateOption> getRateOptions() { return rateOptions; } public void setRateOptions (List <RateOption> options) { this.rateOptions = options; } }
and the RateOption Entity:
@Entity @Table(name="BILLING_RATEOPTIONS") public class RateOption implements java.io.Serializable { private Integer rateoptionId; private Integer calculationalgorithmId; private Integer priceprofileId; private String description; //private char isdefault; private List <AbbeyphonePartner> partners; @Id @Column (name="RATEOPTION_ID") public Integer getRateoptionId() { return this.rateoptionId; } public void setRateoptionId(Integer rateoptionId) { this.rateoptionId = rateoptionId; } @Column (name="CALCULATIONALGORITHM_ID") public Integer getCalculationAlgorithmId() { return this.calculationalgorithmId; } public void setCalculationAlgorithmId(Integer calculationalgorithmId) { this.calculationalgorithmId = calculationalgorithmId; } @Column (name="DESCRIPTION") public String getDescription() { return this.description; } public void setDescription(String description) { this.description = description; } @Column (name="PRICEPROFILE_ID") public Integer getPriceprofileId() { return this.priceprofileId; } public void setPriceprofileId(Integer priceprofileId) { this.priceprofileId = priceprofileId; } // @Column(name="ISDEFAULT") // public char getIsdefault() // { // return this.isdefault; // } // // /** // * @param isdefault the isdefault to set // */ // public void setIsdefault(char isdefault) // { // this.isdefault = isdefault; // } @ManyToMany(fetch = FetchType.EAGER) @JoinTable (name="VOW_PARTNER_RATEOPTIONS", //TODO: HERE! joinColumns={@JoinColumn (name="RATEOPTION_ID")}, inverseJoinColumns={@JoinColumn (name="PARTNER_ID")}) public List<AbbeyphonePartner> getPartners() { return this.partners; } public void setPartners(List<AbbeyphonePartner> partners) { this.partners = partners; } }
The join table would be like this:
- RATEOPTION_ID Integer not null
- PARTNER_ID Integer not null
- ISDEFAULT char(1) // can be Y or N.
I need that ISDEFAULT field but I really don't know how to do it. Thank you very much for any help you can supply.