Pessoal
estou com um problema q esta me deixando louco…
estou usando hibernate com annotations puro, porem nao estou conseguindo fazer funcionar corretamente, na minha aplicação tenho um relacionamento ManyToMany, porem nao estou conseguindo mapea-lo corretamente…
segue o codigo:
@Entity
@Table (name="NEWS")
public class NewsTO implements Serializable{
private static final long serialVersionUID = 1L;
//newsId da noticia
private Long newsId;
//titulo da noticia
private String title;
//conteudo noticia
private String content;
//descricao noticia
private String description;
//fontes noticia
private List<NewsSourceTO> source;
//categorias da noticia
private List<CategoryTO> categories;
//data noticia
private Date date;
@Column (length=2000)
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Temporal(TemporalType.TIMESTAMP)
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@ManyToMany
public List<NewsSourceTO> getSource() {
return source;
}
public void setSource(List<NewsSourceTO> source) {
this.source = source;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@ManyToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
public List<CategoryTO> getCategories() {
return categories;
}
public void setCategories(List<CategoryTO> categories) {
this.categories = categories;
}
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long getNewsId() {
return newsId;
}
public void setNewsId(Long id) {
this.newsId = id;
}
}
@Entity
@Table(name = "CATEGORY")
public class CategoryTO implements Serializable {
private static final long serialVersionUID = 1L;
// id da categoria
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
// nome da ctegoria
private String categoryName;
// tipo da categoria
private Integer categoryType;
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getCategoryType() {
return categoryType;
}
public void setCategoryType(Integer categoryType) {
this.categoryType = categoryType;
}
}
vale lembrar que o objeto category ja esta persistido eu apenas crio um news e coloco uma ou mais categoria dentro e mando persistir… ele nao persiste a tabela de relacionamento…
oq pode ser?