many-to-many mapping

I am trying to do a many to many relationship mapping.

I have succesfully done a one to one relationship so I know some of the basics.

I have followed the roster example.

I am getting this strange error:

ErrorName :com.sun.enterprise.tools.verifier.tests.persistence.DefaultProviderVerification

Error Description : java.lang.StringIndexOutOfBoundsException: String index out of range: 3

at java.lang.String.substring(String.java:1765)

anyone know what this should be telling me?

[527 byte] By [stridersuna] at [2007-11-26 21:50:06]
# 1
me again with a little more info the substring exception is happening in :at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataHelper.getAttributeNameFromMethodName(MetadataHelper.java:99)
stridersuna at 2007-7-10 3:42:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

It is me giving a (sortof) answer to my own question in the hopes it will help somone down the line.

I got it to work here is the working code:

//correct

@ManyToMany(targetEntity=com.mycompany.stereo.database.Accessory.class)

@JoinTable(name="STEREO_ACCESSORY",

joinColumns=

@JoinColumn(name="STEREOID"),

inverseJoinColumns=

@JoinColumn(name="ACCESSORYID")

)

public Set getAccessoryList() {

System.out.println("class: stereo, method:getAccessotyList");

return accessoryList;

}

the problem was I was adding this to the @JoinColumn anotation

@JoinColumn(name="STEREOID", referencedColumnName="id"),

If somone could explain what excactly the referencedColumnName means or does that would be great.

I thought it ment that column STEREOID in the "join table" (stereo_accessory) referenced the column id in the stereo table.

stridersuna at 2007-7-10 3:42:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Hi stridersun,

Thanks for posting your solution. The JPA annotations are described in chapter 9 of the JPA specification, available at:

http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html

The specification has examples showing how annotations can be used. The @JoinColumn annotation is described in 9.1.6.

m_fuchsa at 2007-7-10 3:42:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...