Hello,
I'm using hibernate with the xdoclet V1.2. I have a problem with the primary key objects.
I have a primary key object with two fields. The fields are in a many-to-one relations to another table. I need to create a secondary index for the second field, but the hibernatedoclet cannot implements this into the .hbm.xml file.
My question is, that it is the bug or a feature, or I'm stupid?
The PK object is:
Code:
package mo.hdb.schema.table;
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
public class GalleryArticlePK implements Serializable {
private Gallery gallery;
private Article article;
public GalleryArticlePK() {
}
public GalleryArticlePK(Gallery gallery, Article article) {
this.gallery = gallery;
this.article = article;
}
/**
* @hibernate.many-to-one column="gallery_id" not-null="true"
* @return Gallery
*/
public Gallery getGallery() {
return this.gallery;
}
public void setGallery(Gallery gallery) {
this.gallery = gallery;
}
/**
* @hibernate.many-to-one column="article_id" not-null="true"
* @hibernate.column name="article_id" index="IWOULDLIKETOCREATE"
* @return Article
*/
public Article getArticle() {
return this.article;
}
public void setArticle(Article article) {
this.article = article;
}
public String toString() {
return new ToStringBuilder(this)
.append("gallery", getGallery())
.append("article", getArticle())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof GalleryArticlePK) ) return false;
GalleryArticlePK castOther = (GalleryArticlePK) other;
return new EqualsBuilder()
.append(this.getGallery(), castOther.getGallery())
.append(this.getArticle(), castOther.getArticle())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getGallery())
.append(getArticle())
.toHashCode();
}
}
Regards,
Kincza