飞机航线,机场,飞机都做成CMP,然后3个CMP直接建立关联。

解决方案 »

  1.   

    ejb2.0允许entity bean的属性里有(代表另外一个表的)属性
    部署的时候在xml里说明
      

  2.   

    For your example, you should do as you said. For the three classes/tables stand for three key parts in your applications. Consider another situation, if your plane has a proerty named 'manufactor' indicating which factory produced the plane. And cerntainly there is another table named like 'manufactors' shown below:m_id   int  primary key
    m_name varcharand the relationship between table 'planes' and 'manufactors' is from the foreign key of 'planes' by 'p_manufactor' as shown below:p_manufactor   int references manufactors.m_idHow to deal with it if you think the manufactor is not so important in your application? Yes, do not wrap it as CMP, just make it a normal java class and access it through JDBC/SQL directly. So the CMP 'Plane' will have one property which is simply a int type for manufactor id. Or you can add one more helper property for the instance of class 'Manufactor', the normal class for the table 'manufactors', to let other objects access the Manufactor object but not the manufactor id directly.