Discussion:
Doctrine2 with oracle, sequence generator for the associated table doesn't called
ahmed sabrah
2013-06-17 02:49:07 UTC
Permalink
this problem has made me crazy....!!

i have an Oracle database, there is a many to many relation between Stores
(table name: SELF_STORES) and rental periods (table name:
SELF_RENTAL_PERIODS).

i've generated Entities and controllers for them. When i am trying to add
new store and selecting its related rental periods, Doctrine gets only the
sequence of the store table entity:

SELECT SELFSTORES_ID_SEQ.nextval FROM DUAL

it didn't get the sequence of the intermediate table entity, causing this
error:

An exception occurred while executing 'INSERT INTO SELF_STORES_RENTALPERIODS (STORES_ID, RENTALPERIODS_ID) VALUES (?, ?)' with params {"1":38,"2":3}:
ORA-01400: cannot insert NULL into ("SELF"."SELF_STORES_RENTALPERIODS"."ID")

i've changed the strategy of SelfStoresRentalperiods

@ORM\GeneratedValue(strategy="SEQUENCE")

to "AUTO" and "IDENTITY", with no luck.

i've also noticed that even the prePersist function of the intermediate
table entity "SelfStoresRentalperiods" doesn't called !!

i believe this is a problem in my code.
------------------------------

Here is the code in detailed:

Tables and sequences:

CREATE TABLE "SELF_STORES"
(
"ID" NUMBER NOT NULL ENABLE,
"NAME" VARCHAR2(45 BYTE),
CONSTRAINT "STORES_PK" PRIMARY KEY ("ID") ENABLE
);
"SELF_RENTAL_PERIODS"
(
"ID" NUMBER(*,0),
"NAME" VARCHAR2(255 BYTE),
CONSTRAINT "RENTAL_PERIODS_PK" PRIMARY KEY ("ID") ENABLE
);
"SELF_STORES_RENTALPERIODS"
(
"ID" NUMBER NOT NULL ENABLE,
"STORES_ID" NUMBER,
"RENTALPERIODS_ID" NUMBER,
CONSTRAINT "STORES_RENTALPERIODS_PK" PRIMARY KEY ("ID") ENABLE,
CONSTRAINT "FK_STORES" FOREIGN KEY ("STORES_ID") REFERENCES "SELF_STORES" ("ID") ENABLE,
CONSTRAINT "FK_RENTAL" FOREIGN KEY ("RENTALPERIODS_ID") REFERENCES "SELF_RENTAL_PERIODS" ("ID") ENABLE
);
CREATE SEQUENCE "SELFSTORES_ID_SEQ" INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE ;
CREATE SEQUENCE "SELFSTORES_RENTAL_ID_SEQ" INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE ;
CREATE SEQUENCE "SELFRENTAL_PERIODS_ID_SEQ" INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE ;

i've generate the entities with doctrine console commands:

php app/console doctrine:mapping:import AcmeDemoBundle annotation

then added the many-to-many relation manually, because doctrine doesn't add
it, then generate getters and setters with:

php app/console doctrine:generate:entities AcmeDemoBundle

These are the final entities :

SelfStores Entity:

class SelfStores{
/**
* @var integer
*
* @ORM\Column(name="ID", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="SELFSTORES_ID_SEQ", allocationSize=1, initialValue=1)
*/
private $id;

/**
* Owning Side
*
* @ORM\ManyToMany(targetEntity="SelfRentalPeriods")
* @ORM\JoinTable(name="SELF_STORES_RENTALPERIODS",
* joinColumns={@ORM\JoinColumn(name="STORES_ID", referencedColumnName="ID")},
* inverseJoinColumns={@ORM\JoinColumn(name="RENTALPERIODS_ID", referencedColumnName="ID")}
* )
* used for insert multiple Rentalperiods as ManyToMany
*/
private $rentalPeriods;

/**
* Constructor
*/
public function __construct()
{
$this->rentalPeriods = new \Doctrine\Common\Collections\ArrayCollection();
}

/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}

/**
* Add rentalPeriods
*
* @param \Acme\DemoBundle\Entity\SelfRentalPeriods $rentalPeriods
* @return SelfStores
*/
public function addRentalPeriod(\Acme\DemoBundle\Entity\SelfRentalPeriods $rentalPeriods)
{
$this->rentalPeriods[] = $rentalPeriods;

return $this;
}

/**
* Get rentalPeriods
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getRentalPeriods()
{
return $this->rentalPeriods;
}}

SelfStoresRentalperiods Entity:

namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* SelfStoresRentalperiods
*
* @ORM\Table(name="SELF_STORES_RENTALPERIODS")
* @ORM\Entity
*/
class SelfStoresRentalperiods{
/**
* @var integer
*
* @ORM\Column(name="ID", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="SELFSTORES_RENTAL_ID_SEQ", allocationSize=1, initialValue=1)
*/
private $id;

/**
* @var \SelfStores
*
* @ORM\ManyToOne(targetEntity="SelfStores")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="STORES_ID", referencedColumnName="ID")
* })
*/
private $stores;

/**
* @var \SelfRentalPeriods
*
* @ORM\ManyToOne(targetEntity="SelfRentalPeriods")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="RENTALPERIODS_ID", referencedColumnName="ID")
* })
*/
private $rentalperiods;

/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}

/**
* Set stores
*
* @param \Acme\DemoBundle\Entity\SelfStores $stores
* @return SelfStoresRentalperiods
*/
public function setStores(\Acme\DemoBundle\Entity\SelfStores $stores = null)
{
$this->stores = $stores;

return $this;
}

/**
* Get stores
*
* @return \Acme\DemoBundle\Entity\SelfStores
*/
public function getStores()
{
return $this->stores;
}

/**
* Set rentalperiods
*
* @param \Acme\DemoBundle\Entity\SelfRentalPeriods $rentalperiods
* @return SelfStoresRentalperiods
*/
public function setRentalperiods(\Acme\DemoBundle\Entity\SelfRentalPeriods $rentalperiods = null)
{
$this->rentalperiods = $rentalperiods;

return $this;
}

/**
* Get rentalperiods
*
* @return \Acme\DemoBundle\Entity\SelfRentalPeriods
*/
public function getRentalperiods()
{
return $this->rentalperiods;
}}

SelfRentalPeriods Entity:

class SelfRentalPeriods{
/**
* @var integer
*
* @ORM\Column(name="ID", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="SELFRENTAL_PERIODS_ID_SEQ", allocationSize=1, initialValue=1)
*/
private $id;

/**
* @ORM\ManyToMany(targetEntity="SelfStores", mappedBy="rentalPeriods")
*/
private $stores;

/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}

/**
* Add stores
*
* @param \Acme\DemoBundle\Entity\SelfStores $stores
* @return SelfRentalPeriods
*/
public function addStore(\Acme\DemoBundle\Entity\SelfStores $stores)
{
$this->stores[] = $stores;

return $this;
}

/**
* Get stores
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getStores()
{
return $this->stores;
}}

finally i generated controllers and views with:

php app/console doctrine:generate:crud

In SelfStores controller, the create new form displays rental periods as
checkboxes

when i am trying to save the store, the above error is coming up.
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to doctrine-user-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
ahmed sabrah
2013-06-17 15:38:11 UTC
Permalink
OK, it seems that no one has time to read this long post.
Is there any tutorial explaining, in details, how to create Oracle DB
many-to-many relation with doctrine?
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to doctrine-user-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
ahmed sabrah
2013-06-17 15:50:08 UTC
Permalink
OK, it seems that no one has time to read this long post.
But at least, is there any tutorial explaining, in details, how to create
Oracle DB many-to-many relation with doctrine?
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to doctrine-user-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
Jasper N. Brouwer
2013-06-18 08:15:57 UTC
Permalink
X-Received: by 10.180.10.234 with SMTP id l10mr341896wib.0.1371543358736;
Tue, 18 Jun 2013 01:15:58 -0700 (PDT)
X-BeenThere: doctrine-user-/***@public.gmane.org
Received: by 10.180.92.35 with SMTP id cj3ls495548wib.14.canary; Tue, 18 Jun
2013 01:15:57 -0700 (PDT)
X-Received: by 10.180.207.44 with SMTP id lt12mr3781379wic.5.1371543357712;
Tue, 18 Jun 2013 01:15:57 -0700 (PDT)
Received: from mail-we0-x233.google.com (mail-we0-x233.google.com [2a00:1450:400c:c03::233])
by gmr-mx.google.com with ESMTPS id bj5si5642wib.1.2013.06.18.01.15.57
for <doctrine-user-/***@public.gmane.org>
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Tue, 18 Jun 2013 01:15:57 -0700 (PDT)
Received-SPF: pass (google.com: domain of jasper-***@public.gmane.org designates 2a00:1450:400c:c03::233 as permitted sender) client-ip=2a00:1450:400c:c03::233;
Received: by mail-we0-f179.google.com with SMTP id w59so3098695wes.38
for <doctrine-user-/***@public.gmane.org>; Tue, 18 Jun 2013 01:15:57 -0700 (PDT)
X-Received: by 10.180.185.244 with SMTP id ff20mr7037558wic.0.1371543357630;
Tue, 18 Jun 2013 01:15:57 -0700 (PDT)
Received: from [192.168.1.111] (77-73-227-253.xdsl.nextpertise.nl. [77.73.227.253])
by mx.google.com with ESMTPSA id fb2sm289040wic.4.2013.06.18.01.15.56
for <doctrine-user-/***@public.gmane.org>
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Tue, 18 Jun 2013 01:15:56 -0700 (PDT)
In-Reply-To: <b191e92f-c085-4837-867e-8acaaead164f-/***@public.gmane.org>
X-Mailer: Apple Mail (2.1508)
X-Gm-Message-State: ALoCoQlSE3W5JwL6OQxnOV6n6Sqjy6Q8FIW599tshfwULtGAeR6JCv0olzxwi2X1uMzzRRaehAfL
X-Original-Sender: jasper-***@public.gmane.org
X-Original-Authentication-Results: gmr-mx.google.com; spf=pass
(google.com: domain of jasper-***@public.gmane.org designates 2a00:1450:400c:c03::233
as permitted sender) smtp.mail=jasper-***@public.gmane.org; dkim=pass
header.i=@nerdsweide.nl; dmarc=pass (p=QUARANTINE dis=NONE) d=nerdsweide.nl
Precedence: list
Mailing-list: list doctrine-user-/***@public.gmane.org; contact doctrine-user+owners-/***@public.gmane.org
List-ID: <doctrine-user.googlegroups.com>
X-Google-Group-Id: 52941642618
List-Post: <http://groups.google.com/group/doctrine-user/post>, <mailto:doctrine-user-/***@public.gmane.org>
List-Help: <http://groups.google.com/support/>, <mailto:doctrine-user+help-/***@public.gmane.org>
List-Archive: <http://groups.google.com/group/doctrine-user>
Sender: doctrine-user-/***@public.gmane.org
List-Subscribe: <http://groups.google.com/group/doctrine-user/subscribe>, <mailto:doctrine-user+subscribe-/***@public.gmane.org>
List-Unsubscribe: <http://groups.google.com/group/doctrine-user/subscribe>, <mailto:googlegroups-manage+52941642618+unsubscribe-/***@public.gmane.org>
Archived-At: <http://permalink.gmane.org/gmane.comp.php.doctrine.user/1400>

If you want SELF_STORES_RENTALPERIODS to represent a true many-to-many association, you should remove the ID.

STORES_ID and RENTALPERIODS_ID are foreign keys to their respectable tables, and together they form the primary key of the SELF_STORES_RENTALPERIODS table itself. There should be no other columns in that table.

There will be _no_ entity for SELF_STORES_RENTALPERIODS.


PS: If you _do_ want SELF_STORES_RENTALPERIODS to have an entity, you should create these associations:

Store <- OneToMany -> RentalPeriod <- ManyToOne -> Period


PPS: Personally I find it much easier to code the entities manually, then create/update the db schema using the console (in stead of the other way around).
--
Jasper
Post by ahmed sabrah
this problem has made me crazy....!!
i have an Oracle database, there is a many to many relation between Stores (table name: SELF_STORES) and rental periods (table name: SELF_RENTAL_PERIODS).
SELECT SELFSTORES_ID_SEQ.nextval FROM DUAL
ORA-01400
: cannot insert NULL into ("SELF"."SELF_STORES_RENTALPERIODS"."ID")
i've changed the strategy of SelfStoresRentalperiods
@ORM\GeneratedValue(strategy="SEQUENCE")
to "AUTO" and "IDENTITY", with no luck.
i've also noticed that even the prePersist function of the intermediate table entity "SelfStoresRentalperiods" doesn't called !!
i believe this is a problem in my code.
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to doctrine-user-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
El Tello
2013-06-18 09:41:34 UTC
Permalink
Use the doctrine schema generator. Or generate the tables with the
generator and look if the tables names doesn't match or the Sequence name
doesn't match with that that doctrine tries to use.
Post by Jasper N. Brouwer
If you want SELF_STORES_RENTALPERIODS to represent a true many-to-many
association, you should remove the ID.
STORES_ID and RENTALPERIODS_ID are foreign keys to their respectable
tables, and together they form the primary key of the
SELF_STORES_RENTALPERIODS table itself. There should be no other columns in
that table.
There will be _no_ entity for SELF_STORES_RENTALPERIODS.
PS: If you _do_ want SELF_STORES_RENTALPERIODS to have an entity, you
Store <- OneToMany -> RentalPeriod <- ManyToOne -> Period
PPS: Personally I find it much easier to code the entities manually, then
create/update the db schema using the console (in stead of the other way
around).
--
Jasper
Post by ahmed sabrah
this problem has made me crazy....!!
i have an Oracle database, there is a many to many relation between
SELF_RENTAL_PERIODS).
Post by ahmed sabrah
i've generated Entities and controllers for them. When i am trying to
add new store and selecting its related rental periods, Doctrine gets only
Post by ahmed sabrah
SELECT SELFSTORES_ID_SEQ.nextval FROM DUAL
it didn't get the sequence of the intermediate table entity, causing
An exception occurred while executing 'INSERT INTO
SELF_STORES_RENTALPERIODS (STORES_ID, RENTALPERIODS_ID) VALUES (?, ?)' with
Post by ahmed sabrah
ORA-01400
: cannot insert NULL into ("SELF"."SELF_STORES_RENTALPERIODS"."ID")
i've changed the strategy of SelfStoresRentalperiods
@ORM\GeneratedValue(strategy="SEQUENCE")
to "AUTO" and "IDENTITY", with no luck.
i've also noticed that even the prePersist function of the intermediate
table entity "SelfStoresRentalperiods" doesn't called !!
Post by ahmed sabrah
i believe this is a problem in my code.
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to doctrine-user-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
El Tello
2013-06-18 09:43:24 UTC
Permalink
Where is the sequence definition? Its not in the given SQL
Post by El Tello
Use the doctrine schema generator. Or generate the tables with the
generator and look if the tables names doesn't match or the Sequence name
doesn't match with that that doctrine tries to use.
Post by Jasper N. Brouwer
If you want SELF_STORES_RENTALPERIODS to represent a true many-to-many
association, you should remove the ID.
STORES_ID and RENTALPERIODS_ID are foreign keys to their respectable
tables, and together they form the primary key of the
SELF_STORES_RENTALPERIODS table itself. There should be no other columns in
that table.
There will be _no_ entity for SELF_STORES_RENTALPERIODS.
PS: If you _do_ want SELF_STORES_RENTALPERIODS to have an entity, you
Store <- OneToMany -> RentalPeriod <- ManyToOne -> Period
PPS: Personally I find it much easier to code the entities manually, then
create/update the db schema using the console (in stead of the other way
around).
--
Jasper
Post by ahmed sabrah
this problem has made me crazy....!!
i have an Oracle database, there is a many to many relation between
SELF_RENTAL_PERIODS).
Post by ahmed sabrah
i've generated Entities and controllers for them. When i am trying to
add new store and selecting its related rental periods, Doctrine gets only
Post by ahmed sabrah
SELECT SELFSTORES_ID_SEQ.nextval FROM DUAL
it didn't get the sequence of the intermediate table entity, causing
An exception occurred while executing 'INSERT INTO
SELF_STORES_RENTALPERIODS (STORES_ID, RENTALPERIODS_ID) VALUES (?, ?)' with
Post by ahmed sabrah
ORA-01400
: cannot insert NULL into ("SELF"."SELF_STORES_RENTALPERIODS"."ID")
i've changed the strategy of SelfStoresRentalperiods
@ORM\GeneratedValue(strategy="SEQUENCE")
to "AUTO" and "IDENTITY", with no luck.
i've also noticed that even the prePersist function of the intermediate
table entity "SelfStoresRentalperiods" doesn't called !!
Post by ahmed sabrah
i believe this is a problem in my code.
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to doctrine-user-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
ahmed sabrah
2013-06-18 11:04:00 UTC
Permalink
@Jasper, what about if the join table "SELF_STORES_RENTALPERIODS" has to
keep additional data, not only foreign keys.
for example: i have to keep price in join table. should i change the
relation to:
Store <- OneToMany -> StoreRentalPeriod <- ManyToOne -> RentalPeriod

If so, is there an example explaining that case?
Post by ahmed sabrah
this problem has made me crazy....!!
i have an Oracle database, there is a many to many relation between Stores
SELF_RENTAL_PERIODS).
i've generated Entities and controllers for them. When i am trying to add
new store and selecting its related rental periods, Doctrine gets only the
SELECT SELFSTORES_ID_SEQ.nextval FROM DUAL
it didn't get the sequence of the intermediate table entity, causing this
ORA-01400: cannot insert NULL into ("SELF"."SELF_STORES_RENTALPERIODS"."ID")
i've changed the strategy of SelfStoresRentalperiods
@ORM\GeneratedValue(strategy="SEQUENCE")
to "AUTO" and "IDENTITY", with no luck.
i've also noticed that even the prePersist function of the intermediate
table entity "SelfStoresRentalperiods" doesn't called !!
i believe this is a problem in my code.
------------------------------
CREATE TABLE "SELF_STORES"
(
"ID" NUMBER NOT NULL ENABLE,
"NAME" VARCHAR2(45 BYTE),
CONSTRAINT "STORES_PK" PRIMARY KEY ("ID") ENABLE
);
"SELF_RENTAL_PERIODS"
(
"ID" NUMBER(*,0),
"NAME" VARCHAR2(255 BYTE),
CONSTRAINT "RENTAL_PERIODS_PK" PRIMARY KEY ("ID") ENABLE
);
"SELF_STORES_RENTALPERIODS"
(
"ID" NUMBER NOT NULL ENABLE,
"STORES_ID" NUMBER,
"RENTALPERIODS_ID" NUMBER,
CONSTRAINT "STORES_RENTALPERIODS_PK"<span class="pln" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial;
...
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to doctrine-user-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
Jasper N. Brouwer
2013-06-18 11:45:49 UTC
Permalink
X-Received: by 10.180.98.226 with SMTP id el2mr400315wib.6.1371555967281;
Tue, 18 Jun 2013 04:46:07 -0700 (PDT)
X-BeenThere: doctrine-user-/***@public.gmane.org
Received: by 10.180.79.5 with SMTP id f5ls608227wix.36.gmail; Tue, 18 Jun 2013
04:46:06 -0700 (PDT)
X-Received: by 10.180.12.200 with SMTP id a8mr4094398wic.1.1371555966329;
Tue, 18 Jun 2013 04:46:06 -0700 (PDT)
Received: from mail-we0-x229.google.com (mail-we0-x229.google.com [2a00:1450:400c:c03::229])
by gmr-mx.google.com with ESMTPS id mz18si25935wic.2.2013.06.18.04.46.05
for <doctrine-user-/***@public.gmane.org>
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Tue, 18 Jun 2013 04:46:05 -0700 (PDT)
Received-SPF: pass (google.com: domain of jasper-***@public.gmane.org designates 2a00:1450:400c:c03::229 as permitted sender) client-ip=2a00:1450:400c:c03::229;
Received: by mail-we0-f169.google.com with SMTP id n57so3345705wev.0
for <doctrine-user-/***@public.gmane.org>; Tue, 18 Jun 2013 04:46:05 -0700 (PDT)
X-Received: by 10.180.210.132 with SMTP id mu4mr7530104wic.5.1371555964955;
Tue, 18 Jun 2013 04:46:04 -0700 (PDT)
Received: from [192.168.1.111] (77-73-227-253.xdsl.nextpertise.nl. [77.73.227.253])
by mx.google.com with ESMTPSA id i1sm1462953wiz.6.2013.06.18.04.45.50
for <doctrine-user-/***@public.gmane.org>
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Tue, 18 Jun 2013 04:45:52 -0700 (PDT)
In-Reply-To: <b01762f0-c81f-45ed-9d0a-5c01fb6b7d19-/***@public.gmane.org>
X-Mailer: Apple Mail (2.1508)
X-Gm-Message-State: ALoCoQlsXZMOG3zUWi+VBXCWAwLL/FsqBJogF3rpCCFzFIehZN9D+OtYjqNCSHgtK6T40RUPsDI5
X-Original-Sender: jasper-***@public.gmane.org
X-Original-Authentication-Results: gmr-mx.google.com; spf=pass
(google.com: domain of jasper-***@public.gmane.org designates 2a00:1450:400c:c03::229
as permitted sender) smtp.mail=jasper-***@public.gmane.org; dkim=pass
header.i=@nerdsweide.nl; dmarc=pass (p=QUARANTINE dis=NONE) d=nerdsweide.nl
Precedence: list
Mailing-list: list doctrine-user-/***@public.gmane.org; contact doctrine-user+owners-/***@public.gmane.org
List-ID: <doctrine-user.googlegroups.com>
X-Google-Group-Id: 52941642618
List-Post: <http://groups.google.com/group/doctrine-user/post>, <mailto:doctrine-user-/***@public.gmane.org>
List-Help: <http://groups.google.com/support/>, <mailto:doctrine-user+help-/***@public.gmane.org>
List-Archive: <http://groups.google.com/group/doctrine-user>
Sender: doctrine-user-/***@public.gmane.org
List-Subscribe: <http://groups.google.com/group/doctrine-user/subscribe>, <mailto:doctrine-user+subscribe-/***@public.gmane.org>
List-Unsubscribe: <http://groups.google.com/group/doctrine-user/subscribe>, <mailto:googlegroups-manage+52941642618+unsubscribe-/***@public.gmane.org>
Archived-At: <http://permalink.gmane.org/gmane.comp.php.doctrine.user/1405>

Hi,

Strictly speaking, if your "join table" has additional data, it's no longer a "join table" ;)
(And it really helps _not_ to think of it as a "join table"!)

So yes, in this case you should setup:
Store <- OneToMany -> RentalPeriod <- ManyToOne -> Period

You can find some examples on StackOverflow if you search for "Doctrine OneToMany ManyToOne".
But I don't know of any documentation / tutorial on this subject :(

Because this question is asked very often on this list, writing a blog / gist on this subject is on my list, but I haven't had the time to do this yet :(
--
Jasper
@Jasper, what about if the join table "SELF_STORES_RENTALPERIODS" has to keep additional data, not only foreign keys.
Store <- OneToMany -> StoreRentalPeriod <- ManyToOne -> RentalPeriod
If so, is there an example explaining that case?
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to doctrine-user-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...