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

DDC-1218: Generator disappear with mappedSuperclass and in others common inheritance's cases #1825

Closed
doctrinebot opened this issue Jun 21, 2011 · 6 comments
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user ndm:

With mapped superclass the id lost autoincrement. I've test with yaml and annotation this is the same.

An example with yaml entities :

Document:
  type: mappedSuperclass
  fields:
    mimetype: { type: string, length: 255 }
    filename: { type: string, length: 255 }

Image:
  type: entity
  fields:
    id: { type: integer, id: true, generator: { strategy: AUTO } }

The id in the table Image lost autoincrement.

@doctrinebot
Copy link
Author

Comment created by ndm:

The problem is in file doctrine/lib/Doctrine/ORM/Mapping, a solution, with just one change could be
:

    protected function loadMetadata($name)
    {
        if ( ! $this->initialized) {
...
        // Move down the hierarchy of parent classes, starting from the topmost class
...
            // Invoke driver
            try {
                $this->driver->loadMetadataForClass($className, $class);
            } catch (ReflectionException $e) {
                throw MappingException::reflectionFailure($className, $e);
            }
//Change
            if ($parent) {
//To
            if ($parent && ! $parent->isInheritanceTypeNone()) {
//EndChange
                if ($parent->isIdGeneratorSequence()) {
...
        }

@doctrinebot
Copy link
Author

Comment created by ndm:

I have seen the resolution in doctrine later version, so i hesitate to close this issue.

But i'm sure that the solution in place will not resolve all situation.

By example, if the superclass isn't mapped but an entity with joined, this doesn't work properly, and you lost the id and the generator of the childclass. Another exemple, you want a mapped with generator, and subclass which don't indicate id, you can't the generator isn't include, and the id is required in the subclass.

The code actually work just for same table proposition, and not good, because with same table you must indicate an not used id in the child class ( why an id is an obligation!!!, Sql permit to have table without id).

If somebody read this, i propose a solution for inherited class with another schema,

Each propositions are with a class inheriting from superclass :

####Schema for joinedclass.
In this case generator are leave in the same functions

table_class
  class_id -> **self generator**
table_link
  class_id
  class_discriminent
  superclass_id
table_superclass
  superclass_id -> **self generator**

or better and closest from the actual solution ( with obligation to have different id name)

table_class
  class_id -> **self generator**
  superclass_id
table_superclass
  superclass_id -> **self generator**
  discriminator

####Schema for same table
Not exactly the actual behavior but very near

table_class
   class_id autogenerate (or not exist)
   superclass*id (autogenerate with concatenation class*id and discr or not exit)

The better for me :

table_class
    superclass_id

####Schema for mapped

table_class
  class_id  <--- if exist (not obligatory)
  superclass*id <--- if class_id not exist, the generator from superclass*id
                                    if class*id exist, the generator from class*id

Even with there ideas, the possibility to have more than one generator method could be usefull. (i know that autoincrement can be use just one time). A solution, could be to add generator to field an not to entity in a first time, and treat generator at the end of the process not in the same place that the fields.

So if you read this thank and aufwiedersehen.

@doctrinebot
Copy link
Author

Comment created by holtkamp:

This seems to relate to an issue I created at: http://www.doctrine-project.org/jira/browse/[DDC-1218](http://www.doctrine-project.org/jira/browse/DDC-1218)

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot
Copy link
Author

Comment created by ndm:

Thanks :)

@doctrinebot doctrinebot added this to the 2.1 milestone Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants