Hello, I have next trouble: in the of mapping class, hibernate create table:
CREATE TABLE movie_media_asset ( movie_id BIGINT NOT NULL, promotrailers_id BIGINT NOT NULL, previews_id BIGINT NOT NULL, PRIMARY KEY (movie_id, previews_id), CONSTRAINT fk519177e62df3f0da FOREIGN KEY (movie_id) REFERENCES public.movie (id), CONSTRAINT fk519177e6892787b FOREIGN KEY (previews_id) REFERENCES public.media_asset (id), CONSTRAINT fk519177e6e991c3f7 FOREIGN KEY (promotrailers_id) REFERENCES public.media_asset (id), UNIQUE (promotrailers_id), UNIQUE (previews_id) )
How I can this trouble get round??? Help me, please
Source code:
public class Movie extends implements java.io.Serializable {
private java.util.Set < MediaAsset > previews = new java.util.TreeSet < MediaAsset >(); private java.util.Set < MediaAsset > promoTrailers = new java.util.TreeSet < MediaAsset > ();
// ------------- Relations ------------------ /** * Get the previews Collection * * @return java.util.Set<MediaAsset> */ @javax.persistence.OneToMany(fetch = javax.persistence.FetchType.LAZY) public java.util.Set < MediaAsset > getPreviews() { return this.previews; } /** * Set the previews * * @param previews */ public void setPreviews(java.util.Set < MediaAsset > previews) { this.previews = previews; } /** * Add MediaAsset * * @param mediaAsset */ public void addToPreviews(MediaAsset mediaAsset) { if (mediaAsset == null) return; this.getPreviews().add(mediaAsset); } /** * Remove MediaAsset * * @param mediaAsset */ public void removeFromPreviews(MediaAsset mediaAsset) { if (mediaAsset == null) return; this.getPreviews().remove(mediaAsset); } /** * Get the promoTrailers Collection * * @return java.util.Set<MediaAsset> */ @javax.persistence.OneToMany(fetch = javax.persistence.FetchType.LAZY) public java.util.Set < MediaAsset > getPromoTrailers() { return this.promoTrailers; } /** * Set the promoTrailers * * @param promoTrailers */ public void setPromoTrailers(java.util.Set < MediaAsset > promoTrailers) { this.promoTrailers = promoTrailers; } /** * Add MediaAsset * * @param mediaAsset */ public void addToPromoTrailers(MediaAsset mediaAsset) { if (mediaAsset == null) return; this.getPromoTrailers().add(mediaAsset); } /** * Remove MediaAsset * * @param mediaAsset */ public void removeFromPromoTrailers(MediaAsset mediaAsset) { if (mediaAsset == null) return; this.getPromoTrailers().remove(mediaAsset); } }
public class MediaAsset implements java.io.Serializable { private static final long serialVersionUID = 182342506630035664L; // ----------- Attribute Definitions ------------ private java.lang.String fileName; private java.lang.Long fileSize; private java.lang.Long duration;
}
|