Doctrine 2 one-to-one via composite key

I am trying to set up a relationship as shown below. Each car can have one review. A car has a primary key on 2 columns. Review is referenced back to the car via the composite primary key. Simple, in theory.

class Car { /** * @ORM\Id * @ORM\Column(type="string") */ private $make; /** * @ORM\Id * @ORM\Column(type="string") */ private $model; /** * * @ORM\OneToOne(targetEntity="Review", mappedBy="car", cascade={"persist"}) */ private $review; } class Review { /** * @ORM\Id * @ORM\OneToOne(targetEntity="Car", inversedBy="review") */ private $car; /** * @var @ORM\Column(type="text") */ private $text; }

When I try to generate the schema, the following error pops up.

Column name id referenced for relation from \Entity\Review towards \Entity\Car does not exist.

What am I doing wrong?

-------------Problems Reply------------

After extensive research, I can say that the above structure is not supported by Doctrine, unfortunately.

Category:doctrine2 Views:0 Time:2011-12-02

Related post

  • doctrine 2 - persisting an entity with composite key 2011-04-17

    A Doctrine 2 Entity with a composite key: /** * @Entity */ class Test { /** * @Id * @Column (type="integer", length=11, name="id") * */ protected $id = null; /** * @Id * @Column (type="integer", length=11, name="idtwo") * */ protected $idtwo = null;

  • Can I use two related objects as composite key in Doctrine bundled with Symfony2? 2012-01-05

    Object is ArticleVote and it has two related objects: User and Article. This creates user_id and article_id columns in ArticleVote table. Can I go without using "id" as an id of the table and use a composite key that consists of unique combinaiton of

  • Hibernate mapping a composite key with null values 2008-09-16

    With Hibernate, can you create a composite ID where one of the columns you are mapping to the ID can have null values? This is to deal with a legacy table that has a unique key which can have null values but no primary key. I realise that I could jus

  • Can you use ADO.NET SQLCommandBuilder with composite keys? 2008-10-14

    I have a database table with 6 columns. The primary key is a composite key made up of 5 of the 6 columns I am trying to use the SqlClient.SqlCommandBuilder.GetDeleteCommand to delete the row. However I am getting the following error: "System.InvalidO

  • Composite keys with ActiveScaffold in Ruby On Rails 2008-10-21

    I am developing RoR application that works with legacy database and uses ActiveScaffold plugin for fancy CRUD interface. However one of the tables of my legacy db has composite primary key. I tried using Composite Keys plugin to handle it, but it see

  • Hibernate returns invalid results with composite key 2008-10-22

    I'm getting the strangest results. I have a class with a composite key. If i do the following query: from LOVEJB l order by l.canonicalId desc my results are not ordered by the 'canonicalId' column I asked for. Instead, the canonical id result is lik

  • JPA Composite Key + Sequence 2008-10-28

    Is it possible in plain JPA or JPA+Hibernate extensions to declare a composite key, where an element of the composite key is a sequence? This is my composite class: @Embeddable public class IntegrationEJBPk implements Serializable { //... @ManyToOne(

  • How can I create a foreign key which references an entire composite key? 2008-12-13

    I have two tables one has a three column composite key. The other needs to reference this composite key. What is the syntax for creating a foreign key which references multiple columns. I tried googleing, but I couldn't find it. --------------Solutio

  • Mapping Composite keys in Fluent NHibernate 2009-01-15

    I am new to fluent NHibernate. Now I face one problem with mapping composite keys. Can anyone point out the URL or sample please? --------------Solutions------------- There's a CompositeId method. public class EntityMap : ClassMap<Entity> { pub

  • Edit composite key value using LINQ 2009-01-19

    I have a table which uses three columns as a composite key. One of these column values is used as a sequence tracker for ordered related records. When I insert a new record I have to increment the sequence numbers for the related records that come af

  • Jpa composite key nullable columns 2009-03-23

    I'm using Hibernate's JPA impl to model some tables. I'm having trouble mapping a table that: Has no primary key Has a unique index on 4 columns, 3 of which can be nullable I tried to hack it and define the index as a composite Id, but since some col

  • Composite Key with Hibernate 2009-04-15

    In order to generate the next SQL code: create table users ( user_name varchar(15) not null primary key, user_pass varchar(15) not null); create table user_roles( username varchar(15) not null, role_name varchar(15) not null, primary key(usernmae, ro

  • How to map composite key of entity in JPA? 2009-04-16

    I have the REGION table: REG { id number, dateCreation Date } I have a LOCALE table: LOCALE { locale String } I have a REGION_DESCRIPTION table: REGION_DESCRIPTION { locale String, regId number, description } REGION_DESCRIPTION has a composite key: l

  • In a join table, what's the best workaround for Rails' absence of a composite key? 2009-05-19

    create_table :categories_posts, :id => false do |t| t.column :category_id, :integer, :null => false t.column :post_id, :integer, :null => false end I have a join table (as above) with columns that refer to a corresponding categories table an

  • ManyToMany in Hibernate without composite keys 2009-05-27

    I am dealing with legacy database. And I am writing unit test using pojos & hibernate & HSQLDB. And I am getting the following error: 17:09:03,946 ERROR SchemaExport:349 - Attempt to define a second primary key in statement Let's say I have P

  • Fluent NHibernate Composite key with Dates 2009-06-03

    I'm new to NHibernate and am having difficulty with a simple but stuborn error. I have a table in my DB (MSSQL2008) where the composite key is made up of 2 date columns. These would represent a time period StartDate and EndDate that is unique for the

  • Inserting a record with a Composite Key using NHibernate 2009-06-15

    I am working with a legacy database that uses composite keys. And I am trying to use NHibernate to insert a new record into the database. NHibernate specifies that I have to create the Id manually, but when I try to insert with this id I get the mess

  • Database replication with composite keys? 2009-06-22

    According to the MySQL documentation on database replication, "All tables replicated using row-based replication must have explicit primary keys." Is it safe to assume that database replication will work with a composite keys? --------------Solutions

  • Use composite keys? Or always use surrogate keys? 2009-06-22

    Duplicate: Many to Many Relation Design - Intersection Table Design If I have these tables (* = primary key): user id* name group id* name Is this better? user_group user_id* group_id* Or is this better? user_group id* user_id group_id --------------

  • sql composite key with identity 2009-06-24

    Is it possible to create a composite key in sql 2000 of the form: event_id id2 adf 1 adf 2 adf 3 cfg 1 cfg 2 edf 1 where the id2 restarts the count at each change of event_id. I need the numbering to be exactly like that either by creating a table or

Copyright (C), All Rights Reserved.

processed in 0.094 (s). 11 q(s)