-->
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: OneToMany eclipselink different from hibernate ?
PostPosted: Tue Jul 29, 2008 5:26 am 
Newbie

Joined: Fri Nov 03, 2006 6:53 am
Posts: 5
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 ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 30, 2008 7:49 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

the mapping files look ok, but the interesting question is how and where the entity manager (hibernate session) is used and how transactions are configured.

I have no idea though what EclipseLink really does. Maybe this is a question for their forum?

--Hardy


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.