[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Fetch Type Eager But Objets not retrieved

Kurdt do-not-reply at jboss.com
Mon Sep 24 09:53:25 EDT 2007


Hi All guys

I hope this is not so newbie question, I was an EJB2 developer in the past, and I made the switch to EJB3 with Hibernate, I have an entity defined like this:


  | @Entity
  | @Table(name="USER")
  | public class User implements Serializable {
  | 	
  | 	private Long id;
  | 	private String full_name;
  | 	private String username;
  |         private Level level;
  | 
  | [...]
  | 	
  | 	@OneToOne(fetch=FetchType.EAGER,cascade=CascadeType.MERGE)
  | 	public Level getLevel() {
  | 		return level;
  | 	}
  | 	public void setLevel(Level level) {
  | 		this.level = level;
  | 	}
  | 
  | 

"Level" is another entity, and a table One to One relation at Database.

The problem is that when I retrieve one "User" from the DB the "level" object is not being populated (it is null), even that I set the Fetch Type to Eager.

What am I missing?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087916#4087916

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087916



More information about the jboss-user mailing list