[jboss-user] [EJB 3.0] - NewBie @OneToOne question
delarue
do-not-reply at jboss.com
Fri Mar 13 10:58:18 EDT 2009
Hi, I am currently learning EJB3 and I don't know express in EJB3 the following
SQL:
anonymous wrote : USER(
| user_id : int primary key
| mycar_id : int
| foreignkey(mycar_FK) (mycar_id, CAR.id)
| )
|
| CAR(car_id : int primary key)
|
This is a OneToOne association
@Entity
| @Table(name="USER")
| class User{
| @Id
| @Column(name="user_id")
| protected int userId;
| ...
| @OneToOne
| @JoinColumn(name="mycar_FK",
| referencedColumnName="xxx")
| public Car getMyCar() ...
| }
I don't know if referencedColumnName identifies the column USER.mycar_id or the column of the target id, CAR.car_id ?
If it is mycar_id, how is done the identification of the id of CAR, CAR.car_id ?
If it is CAR.car_id, how is identified the mycar_id column ?
@Entity
| ...
| class Car {
| @Id
| @Column(name="car_id")
| protected int carId;
| ...
| }
I have the EJB in action book and often the foreign key and primary key have the same column name, which cause misunderstanding from my side.
Is there a sample server, which genererate the SQL code from a EJB annotation ... without testing it on a free base ?
I understood that in EJB3, the schema of a database should be created outside of the EJB3 annotation. EJB annotation should be a model expression of some sql definition. Therefore, I try to understand the EJB modeling of some SQL samples.
Thank's for help
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4217890#4217890
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4217890
More information about the jboss-user
mailing list