-->
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: Many To Many using a middletable
PostPosted: Wed Jun 20, 2007 11:34 am 
Newbie

Joined: Tue Jun 12, 2007 10:25 am
Posts: 3
Hi,

I have 3 tables :
- artist (PK = id_artist)
- song (PK = id_song)
- artist_has_song (FK = FK_artist_has_song and FK_song_belong_to_artist)

There is a many-to-many relation between artist and song.

I want to generate domain code and DAO from database using reverse engineering.

When I use hibernate-tools version 3.2.0.beta9a, I get the following code :


Code:
public class Artiste implements java.io.Serializable {
...
    @ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY,   
    mappedBy="artistes")
    public Set<Song> getSongs() {
        return this.songs;
    }

}

public class Song implements java.io.Serializable {
...
    @ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY,   
    mappedBy="songs")
    public Set<Artiste> getArtistes() {
        return this.artistes;
    }

}


Whereas I'd like to have this code :

Code:
public class Artiste implements java.io.Serializable  {   
...       
        @ManyToMany(mappedBy="artisteCollection")
   private Set<Mxp4> mxp4Collection;

}

public class Song implements java.io.Serializable {
...
        @ManyToMany
   @JoinTable(name="artiste_has_song",
      joinColumns=@JoinColumn(name="id_song"),
      inverseJoinColumns=@JoinColumn(name="id_artiste"))
   private Set<Artiste> artisteCollection;

}


I tried to configure it in a custom strategy and in a reveng.xml file but I didn't succeed in.
Do I have to change the pojo.ftl too?

I don't know what is the best way to do it.

Thanks for your help!
Gael


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.