Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isPartOfKey not being set correcting for keys in Embeddable properties #23

Open
jasonlfunk opened this issue Oct 9, 2015 · 3 comments

Comments

@jasonlfunk
Copy link

I have my keys stored in a UUID value object. When this is generating the metadata, the isPartOfKey flag is not being properly set for the classes.

Example:

/**
 * @Entity
 * @HasLifecycleCallbacks()
 **/
class Expense extends Base
{
    /**
     * @Embedded(class="Objects\UUID", columnPrefix=false)
     * @var UUID
     **/
    protected $id;
   ....
}
/**
 * @Embeddable
 */
class UUID
{
    /**
     * @Id
     * @Column(type="string")
     */
    private $id;

   ...
}

The generated Metadata looks like this:

{
"metadataVersion":"1.0.5",
"structuralTypes":[{
   "shortName":"Expense",
   "autoGeneratedKeyType":"None",
   "defaultResourceName":"Expenses",
   "dataProperties":[
      {"name":"id","dataType":"String"}
      ...
   ]
}

It appears that Embeddables aren't being evaluated correctly.

@safrazik
Copy link
Owner

Embeddables is a Doctrine 2.5 feature. Yes it's not supported by the library yet. I'll have a look at the issue. Please feel free to contribute!

@safrazik
Copy link
Owner

ok! Embeddables are the breeze equivalent of Complex Types.
Relating to your issue: The Doctrine documentation says embeddables don’t have a primary key which makes sense as they are not entities, but your UUID embeddable has a primary key like an entity. I think it is wrong. Second, your Expense entity has a primary key which is type of an embeddable. I wonder if Doctrine library supports Embeddable to be a primary key of en entity type.

@jasonlfunk
Copy link
Author

Hi - thanks for responding.

  1. You are right that an embeddable doesn't have a primary key because they aren't entities. However, they can provide the primary key for another entity. This setup is currently working fine with my application.

  2. Expense doesn't have a primary key directly (there is no @id mapping on it). It get's inherited from the UUID embeddable.

Here are the relevant parts of the generated mapping:

+-------------------------------+--------------------------------------------+
| Field                         | Value                                      |
+-------------------------------+--------------------------------------------+
| Name                          | Expense                                    |
| Root entity name              |Expense                                     |
| Custom generator definition   | None                                       |
| Custom repository class       | None                                       |
| Mapped super class?           | False                                      |
| Embedded class?               | False                                      |
| Parent classes                | Empty                                      |
| Sub classes                   | Empty                                      |
| Embedded classes              | Empty                                      |
| Identifier                    | ["id.id"]                                  |
| Inheritance type              | 1                                          |
| Discriminator column          | None                                       |
| Discriminator value           | None                                       |
| Discriminator map             | Empty                                      |
| Generator type                | 5                                          |
| Table                         | {"name":"Expense"}                         |
| Composite identifier?         | False                                      |
| Foreign identifier?           | False                                      |
| Sequence generator definition | None                                       |
| Table generator definition    | None                                       |
| Association mappings:         |                                            |
|   id.id                       |                                            |
|     fieldName                 | id.id                                      |
|     type                      | string                                     |
|     length                    | Null                                       | 
|     unique                    | False                                      |
|     nullable                  | False                                      |
|     id                        | True                                       |
|     columnName                | id                                         |
|     originalClass             | UUID                                       |
|     declaredField             | id                                         |
|     originalField             | id                                         |
+-------------------------------+--------------------------------------------+

+-------------------------------+---------------------------+
| Field                         | Value                     |
+-------------------------------+---------------------------+
| Name                          | UUID                      |
| Root entity name              | UUID                      |
| Custom generator definition   | None                      |
| Custom repository class       | None                      |
| Mapped super class?           | False                     |
| Embedded class?               | True                      |
| Parent classes                | Empty                     |
| Sub classes                   | Empty                     |
| Embedded classes              | Empty                     |
| Named queries                 | Empty                     |
| Named native queries          | Empty                     |
| SQL result set mappings       | Empty                     |
| Identifier                    | ["id"]                    |
| Inheritance type              | 1                         |
| Discriminator column          | None                      |
| Discriminator value           | None                      |
| Discriminator map             | Empty                     |
| Generator type                | 5                         |
| Table                         | {"name":"UUID"}           |
| Composite identifier?         | False                     |
| Foreign identifier?           | False                     |
| Sequence generator definition | None                      |
| Table generator definition    | None                      |
| Change tracking policy        | 1                         |
| Versioned?                    | None                      |
| Version field                 | None                      |
| Read only?                    | False                     |
| Entity listeners              | Empty                     |
| Association mappings:         |                           |
| Field mappings:               |                           |
|   id                          |                           |
|     fieldName                 | id                        |
|     type                      | string                    |
|     scale                     | Empty                     |
|     length                    | Null                      |
|     unique                    | False                     |
|     nullable                  | False                     |
|     precision                 | Empty                     |
|     id                        | True                      |
|     columnName                | id                        |
+-------------------------------+---------------------------+

I was hoping something would just ring a bell and there would be an easy fix. I don't have too much experience with Reflection and what-not. But I'll definitely dig into it a little more too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants