[jboss-user] [EJB 3.0] - Embedded Objects set to null by entitymanager

mwoelke do-not-reply at jboss.com
Mon Aug 14 13:18:41 EDT 2006


Hi,
We've got a problem with embedded objects. Imagine the following scenario:

@Entity
  | class A{
  | 	int id;
  | 	B embedded;
  | 
  | 	public A(){
  |   		embedded = new B();
  | 	}
  | 
  | 	@Embedded
  | 	public B getEmbedded(){
  | 		return embedded;
  | 	}
  | 
  | 	... other getters and setters ... nothing special ...
  | }
  | 
  | @Embeddable
  | class B{
  | 	String name;
  | 	String shortName;
  | 	public String getName(){...}
  | 	public String getShortName(){...}
  | 	... setters ...
  | }

If name or shortName of B is set to a value other than null everything works fine, which means A.embedded is set to a non null value when fetching it from the db. BUT, if both properties of B are set to null, A.embedded itself is set to null, too.
This happens although the default constructor which gets called by the entity manager sets it to a non null value.

Does anyone know this behavior? Is it what its is supposed to be? And how to deal with that if its necessary to have A.embedded always set to a non null value.

We are still using JBoss 4.0.4 RC1. Is this a known issue? Should we switch to 4.0.4GA? Any help is appreciated.

Thanx in advance.

Milan Wölke

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

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




More information about the jboss-user mailing list