But the container will create table EntityA_Table and EntityB_Table:
> CREATE TABLE EntityA_Table (ID varchar (50) PRIMARY KEY,_EntityA_EntityB varchar(50))
> CREATE TABLE EntityB_Table (ID varchar (50) PRIMARY KEY,_EntityB_EntityA varchar(50))
the tables would be created as follows depending on where u specify the foreign key
CREATE TABLE EntityA_Table (ID varchar (50) PRIMARY KEY, EntityB_ID varchar(50))
CREATE TABLE EntityB_Table (ID varchar (50) PRIMARY KEY)
> But the column for relation is as same as the primary key column, the question is below:
> Q1: Does the cmp field and cmr field can not be the same database table column? If so, it will waste the disk space.
You can have a cmp field that describes the value of the FK. The CMR field is the actual Entity Bean that is represents the FK. So you would could have a cmp getter
abstract String getEntityB_PK()
and a CMR getter
abstract EntityB getEntityB()
> Q2: which one is more common or more better?
> 1)create database table first and create CMP based on table.
If you have a legacy db or you don't have create access in the db the table would have to be there first, but if you have dbo access there is no reason no to let the container create the tables, you can always tweak them afterwards without starting from scratch.
as for the other 2 what ever makes your life easier. I personally like using XDoclet to generate my descriptors as well as interfaces, PKs, etc. from one source file.
> 2)create CMP first and create table from EJB descriptor thought EJB container when deploying.
> 3)create CMP first and create table from EJB descriptor by manual.