doujiaozhao2489 2014-09-25 13:41
浏览 28

Doctrine2:如何映射2个实体

I seem to be having a lot of trouble mapping 2 entities in Doctrine2.

I have a class User, a class Person and a class Candidate. Both Person and Candidate extend from User, in a "Is an"-relation, so both Person and Candidate should have a oneToOne relation with User. Both Person and Candidate have a property "userid" which is the foreign key that should map to the userid from User.

This all seems rather simple but I can't get it to work. When looking at the documentation of Doctrine (http://doctrine-orm.readthedocs.org/en/latest/reference/inheritance-mapping.html?highlight=DiscriminatorColumn#single-table-inheritance), I cannot use Mapped Superclasses because I want user to be an entity as well. And I cannot use Single Table Inheritance because I do not have an DiscriminatorColumn.

I have all the necessary tables in my PostgreSql database, and I'm using yml for the necessary mapping files.

Anyone that can point me in the right direction?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度