Hello !
I've the following misunderstanding please help :)
@Entity
public class Blog implements Serializable{
@Id
@Column(name="blogId")
private String id;
private String title;
@OneToMany(cascade=CascadeType.ALL, mappedBy="blog")
@JoinColumn(unique=true, name="entryId" )
private Set<Entry> entries=new HashSet<Entry>();
public Set<Entry> getEntries() {
return entries;
}
public void setEntries(Set<Entry> entries) {
this.entries = entries;
}
public void addEntry(Entry entry){
entry.setBlog(this);
entries.add(entry);
}
.....
}
@Entity
public class Entry implements Persistable<Long>{
@Transient
public static final String FIND_BLOG_ENTRY="findBlogEntry";
@Transient
private static final long serialVersionUID = 4968311347450430770L;
@Id @GeneratedValue
@Column(name="entryId")
private Long id=null;
@ManyToOne
@JoinColumn(name="blogId", nullable=false)
private Blog blog;
public Blog getBlog() {
return blog;
}
public void setBlog(Blog blog) {
this.blog = blog;
}
.....
}
public class BlogServiceImpl implements BlogService{
....
public EntryDto saveEntry(String blogId,EntryDto entryDto) {
Blog blog=blogRepository.get(blogId);
Entry e=new Entry();//createEntry(entryDto);
blog.addEntry(e);
return createEntryDto(e);
}
....
}
So using Hibernate JPA new entry is created but using Eclipselink no new entry is created . Could anybody explain why ?
|