Fix some more details in basic-mapping.rst
This commit is contained in:
parent
a948cb49b8
commit
9983fcbac3
@ -368,30 +368,31 @@ besides specifying the sequence's name:
|
|||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
class User
|
class Message
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Id
|
* @Id
|
||||||
* @GeneratedValue(strategy="SEQUENCE")
|
* @GeneratedValue(strategy="SEQUENCE")
|
||||||
* @SequenceGenerator(sequenceName="tablename_seq", initialValue=1, allocationSize=100)
|
* @SequenceGenerator(sequenceName="message_seq", initialValue=1, allocationSize=100)
|
||||||
*/
|
*/
|
||||||
protected $id = null;
|
protected $id = null;
|
||||||
|
//...
|
||||||
}
|
}
|
||||||
|
|
||||||
.. code-block:: xml
|
.. code-block:: xml
|
||||||
|
|
||||||
<doctrine-mapping>
|
<doctrine-mapping>
|
||||||
<entity name="User">
|
<entity name="Message">
|
||||||
<id name="id" type="integer">
|
<id name="id" type="integer">
|
||||||
<generator strategy="SEQUENCE" />
|
<generator strategy="SEQUENCE" />
|
||||||
<sequence-generator sequence-name="tablename_seq" allocation-size="100" initial-value="1" />
|
<sequence-generator sequence-name="message_seq" allocation-size="100" initial-value="1" />
|
||||||
</id>
|
</id>
|
||||||
</entity>
|
</entity>
|
||||||
</doctrine-mapping>
|
</doctrine-mapping>
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
MyPersistentClass:
|
Message:
|
||||||
type: entity
|
type: entity
|
||||||
id:
|
id:
|
||||||
id:
|
id:
|
||||||
@ -399,7 +400,7 @@ besides specifying the sequence's name:
|
|||||||
generator:
|
generator:
|
||||||
strategy: SEQUENCE
|
strategy: SEQUENCE
|
||||||
sequenceGenerator:
|
sequenceGenerator:
|
||||||
sequenceName: tablename_seq
|
sequenceName: message_seq
|
||||||
allocationSize: 100
|
allocationSize: 100
|
||||||
initialValue: 1
|
initialValue: 1
|
||||||
|
|
||||||
@ -439,15 +440,14 @@ need to access the sequence once to generate the identifiers for
|
|||||||
Composite Keys
|
Composite Keys
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Doctrine 2 allows to use composite primary keys. There are however
|
with Doctrine 2 you can use composite primary keys, using ``@Id`` on more then
|
||||||
some restrictions opposed to using a single identifier. The use of
|
one column. Some restrictions exist opposed to using a single identifier in
|
||||||
the ``@GeneratedValue`` annotation is only supported for simple
|
this case: The use of the ``@GeneratedValue`` annotation is not supported,
|
||||||
(not composite) primary keys, which means you can only use
|
which means you can only use composite keys if you generate the primary key
|
||||||
composite keys if you generate the primary key values yourself
|
values yourself before calling ``EntityManager#persist()`` on the entity.
|
||||||
before calling ``EntityManager#persist()`` on the entity.
|
|
||||||
|
|
||||||
To designate a composite primary key / identifier, simply put the
|
More details on composite primary keys are discussed in a :doc:`dedicated tutorial
|
||||||
@Id marker annotation on all fields that make up the primary key.
|
<../tutorials/composite-primary-keys>`.
|
||||||
|
|
||||||
Quoting Reserved Words
|
Quoting Reserved Words
|
||||||
----------------------
|
----------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user