[jboss-user] [EJB 3.0] - mappedBy reference an unknown target entity property

svanbegin01 do-not-reply at jboss.com
Thu Nov 16 11:00:18 EST 2006


I would like to define a ManyToMany association between
2 Entities A and C.
As an additional property is required in the JoinTable, I tried
to define 2 OneToMany associations involving a new entity B.

Each time I deploy on jboss-4.0.5.GA, I get this error:
org.hibernate.AnnotationException :
mappedBy reference an unknown target entity property :
com.acme.dev001.ejb.B.a in com.acme.dev001.ejb.A.bs

What's wrong in the code that follows ?


--------------- A -----------------------
@Entity
public class A implements java.io.Serializable {

	@Id
	private short aNo;

	@OneToMany(	
				targetEntity = com.acme.dev001.ejb.B.class,
				cascade = CascadeType.ALL,
				fetch = FetchType.EAGER,
				mappedBy = "a"
			)
	private Collection< B> bs = new ArrayList< B>();
	
--------------- B -----------------------
@IdClass(com.acme.dev001.ejb.BKey.class)
@Entity
public class B implements java.io.Serializable {

	@Id
	@ManyToOne(targetEntity=com.acme.dev001.ejb.A.class)
	@JoinColumn(name="aNo", nullable=false, updatable=false, insertable=false)
	private A a;

	@Id
	@ManyToOne(targetEntity=com.acme.dev001.ejb.C.class)
	@JoinColumn(name="cNo", nullable=false, updatable=false, insertable=false)
	protected C c;

--------------- C -----------------------
@Entity
public class C implements java.io.Serializable {

	@Id
	private short cNo;

	@OneToMany(	
				targetEntity = com.acme.dev001.ejb.B.class,
				cascade = CascadeType.ALL,
				fetch = FetchType.EAGER,
				mappedBy = "c"
			)
	private Collection< B> bs = new HashSet< B>();
--------------------------------------------

Thanks,
Serge



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

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



More information about the jboss-user mailing list