[jboss-user] [EJB 3.0] - Re: NewBie @OneToOne question

Wolfgang Knauf do-not-reply at jboss.com
Fri Mar 13 11:26:54 EDT 2009


Hi,

I think that the "name" attribute of the "@JoinColumn" denotes the column name in your "User" table. The "referencedColumn" should be the name of the primary key column in your child table.

So, to achieve your sql snippet, your relationship should be:

@OneToOne
  |    @JoinColumn(name="mycar_id",
  |            referencedColumnName="car_id")
  |    public Car getMyCar() ...

But normally the @OneToOne annotation should work without any @JoinColumn annotations. The server will choose defaults for the column names. So, start with the easiest solution and remove the @JoinColumn annotation ;-). 

Hope this helps

Wolfgang

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

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



More information about the jboss-user mailing list