Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Incomplete
-
Affects Version/s: 2.1
-
Fix Version/s: None
-
Component/s: Mapping Drivers
-
Security Level: All
-
Labels:None
-
Environment:ubuntu 64x
Description
Hi!
Ran into a problem while wanted to use a ManyToOne as part of a primary key:
* @Entity * @Table(name="user_preferences") */ class UserPreferences { /** * @Id * @ManyToOne(targetEntity="User",cascade={"persist"}) * @JoinColumn(name="user_id", referencedColumnName="id") */ protected $user; /** * @Id * @GeneratedValue(strategy="NONE") * @Column(name="preference_id",type="smallint",nullable=false) */ protected $preference_id;
By default doctrine creates a table with 2 single keys (the preference key is the primary key) which is of course incorrect.
Had to add @Column(name="user_id",type="integer") to the user column to fix the index problem but that introduced another problem. The entity no longer accepter \Entity\User as a value for user and takes only a smallint as defined.
No feedback given