I can't get @PrePersist to work.
Here's my entity
namespace Sensio\HelloBundle\Entity;
/**
*
@orm:Entity(repositoryClass="Sensio\HelloBundle\Entity\Repository\CustomerRepository")
*/
class Customer
{
/**
* @orm:id
* @orm:Column(type="integer")
* @orm:GeneratedValue(strategy="AUTO")
* @orm:HasLifecycleCallbacks
*/
protected $id;
/** @orm:Column(type="string",length="50")
* @var string
*/
protected $name;
/** @orm:Column(type="datetime", nullable="true")
* @var \DateTime
* @validation:NotBlank
*/
protected $createdAt;
/** @PrePersist */
public function PrePersist()
{
exit;
$this->createdAt = new \DateTime('now');
}
I get the following error:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'createdAt'
cannot be null
Also, how come I have to set "nullable=true" for each field to prevent the
error? I've used Doctrine2 before and never had to. Is there a better way?
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en