[jboss-user] [EJB 3.0] - How to access a join table column?!
fabiorusso
do-not-reply at jboss.com
Mon Jul 24 13:10:24 EDT 2006
Hello. 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.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960470#3960470
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960470
More information about the jboss-user
mailing list