-->
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.  [ 2 posts ] 
Author Message
 Post subject: Table duplicated
PostPosted: Mon Nov 05, 2007 10:49 am 
Newbie

Joined: Fri Jun 09, 2006 6:34 pm
Posts: 5
hello. I have these:

Code:
@Entity
@Table(name="midiaator")
public class MidiaAtor {
   
   
   @Embeddable
   public static class Ids implements Serializable{
      
      @Column(name="idAtor")
      private Long idAtor;
      
      @Column(name="idMidia")
      private Long idMidia;
      
      public Ids(){}
      
      public void setIds(Long idMidia, Long idAtor){
         this.idMidia = idMidia;
         this.idAtor = idAtor;
      }

      public Long getIdAtor() {
         return idAtor;
      }

      public Long getIdMidia() {
         return idMidia;
      }
   }
   
   @EmbeddedId
   Ids ids = new Ids();
   
   
   @ManyToOne
   @JoinColumn(name="idMidia", insertable=false, updatable=false)
   private Midia midia;
   
   @ManyToOne
   @JoinColumn(name="idAtor", insertable=false, updatable=false)
   private Ator ator;


Code:
@Entity
@Table(name="ator")
public class Ator {
   
   @Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   private Long id;
   @Column(length=200)
   private String nome;
   
   
   @OneToMany(mappedBy="ator")
   private Set<MidiaAtor> ma;
   
   
   public Set<MidiaAtor> getMa() {
      return ma;
   }
   public void setMa(Set<MidiaAtor> ma) {
      this.ma = ma;
   }
   public Long getId() {
      return id;
   }
   public void setId(Long id) {
      this.id = id;
   }
   public String getNome() {
      return nome;
   }
   public void setNome(String nome) {
      this.nome = nome;
   }


Code:
@Entity
@Table(name="midia")
public class Midia {
   @Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   private Long id;
   
   @Column(length=200)
   private String nome;

   
   @OneToMany (mappedBy="")
   private Set<MidiaAtor> ma;
   


Why is it being duplicated the table MidiaAtor?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 06, 2007 7:27 am 
Newbie

Joined: Sat Oct 13, 2007 12:42 pm
Posts: 5
Hi MrsMylle,


I really don't understand your question but, i think you are trying to find out why this lines

Code:
@OneToMany(mappedBy="ator")
   private Set<MidiaAtor> ma;


really exists.

This is not a MidiaAtor duplication, is just a way to connect your Ator entity to your MidiAtor entity, it's not duplicating anything.

Maybe it's a good idea to take a look in hibernate basics.

http://www.hibernate.org/hib_docs/annotations/reference/en/html/


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

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.