-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: XDoclet primary key and secondary indexes
PostPosted: Mon Apr 26, 2004 10:49 am 
Newbie

Joined: Fri Mar 19, 2004 11:39 am
Posts: 4
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.