0

エンティティをデータベースに永続化しようとすると、the ORA-01861: literal does not match format stringエラーが発生します。ほとんどの場合、日付と文字列の変換の間のエラーがこのメッセージにつながることを知っています。私もそうかもしれませんが、原因がわかりません。これがSQLステートメントです(プロファイラーから):

INSERT INTO Person (no_person, first_name, usual_name, last_name,
birth_date, comments, c_user_creation, date_creation, c_user_modification, 
date_modification, email, id_rh, cod_civ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ? ) Parameters: { 1: '173704', 2: Test, 3: 'null', 4: Test, 5: Object(DateTime), 6: 'null', 
7: Web, 8: Object(DateTime), 9: 'null', 10: 'null', 11: zefzf@dgeghte.fr, 12: 'null', 13: '1'}
Time: 0.00 ms 

Person エンティティ:

<?php

namespace my\myBundle\Entity;

 use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\UploadedFile;

/**
 * my\myBundle\Entity\Person
 *
 * @ORM\Table(name="Person")
 * @ORM\Entity(repositoryClass="my\myBundle\Entity\PersonRepository")
 */
class Person
{
/**
 *
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="SEQUENCE")
 * @ORM\Column(name="no_Person", type="integer")
 * @ORM\SequenceGenerator(sequenceName="SEQ_NO_Person")
 */
public $noPerson;

/**
 *
 * @ORM\ManyToOne(targetEntity="civility")
 * @ORM\JoinColumn(name="cod_civ", referencedColumnName="cod_civ")
 */
private $civility;

/**
 * @var string $firstName
 *
 * @ORM\Column(name="first_name", type="string", length=30)
 */
private $firstName;

/**
 * @var string $usualName
 *
 * @ORM\Column(name="usual_name", type="string", length=30)
 */
private $usualName;

/**
 * @var string $lastName
 *
 * @ORM\Column(name="last_name", type="string", length=20)
 */
private $lastName;

/**
 * @var date $birthDate
 *
 * @ORM\Column(name="birth_date", type="date")
 */
private $birthDate;

/**
 * @var string $comment
 *
 * @ORM\Column(name="comment", type="string", length=300)
 */
private $comment;

/**
 * @var string $cUserCreation
 *
 * @ORM\Column(name="c_user_creation", type="string", length=30)
 */
private $cUserCreation;

/**
 * @var date $dCreation
 *
 * @ORM\Column(name="date_creation", type="date")
 */    
private $dCreation;

/**
 * @var string $cUserModification
 *
 * @ORM\Column(name="c_user_modification", type="string", length=30)
 */
private $cUserModification;

/**
 * @var date $dModification
 *
 * @ORM\Column(name="date_modification", type="date")
 */    
private $dModification;

/**
 * @var string $email
 *
 * @ORM\Column(name="email", type="string", length=100)
 */
private $email;

/**
 * @var integer $idRh
 *
 * @ORM\Column(name="id_rh", type="integer")
 */
private $idRh;

/**
 * @var \Doctrine\Common\Collections\ArrayCollection $accCip
 *
 * @ORM\OneToMany(targetEntity="my\myBundle\Entity\AccCip",mappedBy="Person")
 */

private $accCip;


/**
 * @var \Doctrine\Common\Collections\ArrayCollection $cartes
 *
 * @ORM\OneToMany(targetEntity="my\myBundle\Entity\Carte",mappedBy="Person")
 */

private $cartes;

/**
 * @var \Doctrine\Common\Collections\ArrayCollection $panier
 *
 * @ORM\OneToMany(targetEntity="my\myBundle\Entity\Panier",mappedBy="Person")
 */

private $panier;

/**
 * @var \Doctrine\Common\Collections\ArrayCollection $transactions
 *
 * @ORM\OneToMany(targetEntity="my\myBundle\Entity\TransactionPaybox",mappedBy="Person")
 */

private $transactions;

/**
 * @var my\myBundle\Entity\Adresse $adresses
 *
 * @ORM\OneToMany(targetEntity="my\myBundle\Entity\Adresse",mappedBy="Person",cascade={"persist"})
 */
private $adresses;

public function __construct()
{
    $this->cUserCreation = "Web";
    $this->dCreation = new \DateTime();
    $this->birthDate = new \DateTime();
    $this->cartes = new \Doctrine\Common\Collections\ArrayCollection();
    $this->accCip = new \Doctrine\Common\Collections\ArrayCollection();
    $this->panier = new \Doctrine\Common\Collections\ArrayCollection();
    $this->transactions = new \Doctrine\Common\Collections\ArrayCollection();
    $this->insActSpos = new \Doctrine\Common\Collections\ArrayCollection();
    $this->adresses = new \Doctrine\Common\Collections\ArrayCollection();
}

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

/**
 * Set firstName
 *
 * @param string $firstName
 */
public function setfirstName($firstName)
{
    $this->firstName = $firstName;
}

/**
 * Get firstName
 *
 * @return string 
 */
public function getfirstName()
{
    return $this->firstName;
}

/**
 * Set usualName
 *
 * @param string $usualName
 */
public function setusualName($usualName)
{
    $this->usualName = $usualName;
}

/**
 * Get usualName
 *
 * @return string 
 */
public function getusualName()
{
    return $this->usualName;
}

/**
 * Set lastName
 *
 * @param string $lastName
 */
public function setlastName($lastName)
{
    $this->lastName = $lastName;
}

/**
 * Get lastName
 *
 * @return string 
 */
public function getlastName()
{
    return $this->lastName;
}

/**
 * Set birthDate
 *
 * @param string $birthDate
 */
public function setbirthDate(\DateTime $birthDate)
{
    $this->birthDate = clone $birthDate;
}

/**
 * Get birthDate
 *
 * @return string 
 */
public function getbirthDate()
{
    return $this->birthDate;
}

/**
 * Set comment
 *
 * @param string $comment
 */
public function setcomment($comment)
{
    $this->comment = $comment;
}

/**
 * Get comment
 *
 * @return string 
 */
public function getcomment()
{
    return $this->comment;
}

/**
 * Set cUserCreation
 *
 * @param string $cUserCreation
 */
public function setCUserCreation($cUserCreation)
{
    $this->cUserCreation = $cUserCreation;
}

/**
 * Get cUserCreation
 *
 * @return string 
 */
public function getCUserCreation()
{
    return $this->cUserCreation;
}

/**
 * Set dCreation
 *
 * @param string $dCreation
 */
public function setDCreation(\DateTime $dCreation)
{
    $this->dCreation = clone $dCreation;
}

/**
 * Get dCreation
 *
 * @return string 
 */
public function getDCreation()
{
    return $this->dCreation;
}

/**
 * Set cUserModification
 *
 * @param string $cUserModification
 */
public function setCUserModification($cUserModification)
{
    $this->cUserModification = $cUserModification;
}

/**
 * Get cUserModification
 *
 * @return string 
 */
public function getCUserModification()
{
    return $this->cUserModification;
}

/**
 * Set dModification
 *
 * @param string $dModification
 */
public function setDModification(\DateTime $dModification)
{
    $this->dModification = clone $dModification;
}

/**
 * Get dModification
 *
 * @return string 
 */
public function getDModification()
{
    return $this->dModification;
}

/**
 * Set email
 *
 * @param string $email
 */
public function setEmail($email)
{
    $this->email = $email;
}

/**
 * Get email
 *
 * @return string 
 */
public function getEmail()
{
    return $this->email;
}

/**
 * Set idRh
 *
 * @param integer $idRh
 */
public function setIdRh($idRh)
{
    $this->idRh = $idRh;
}

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

/**
 * Set civility
 *
 * @param my\myBundle\Entity\civility $civility
 */
public function setcivility(\my\myBundle\Entity\civility $civility)
{
    $this->civility = $civility;
}

/**
 * Get civility
 *
 * @return my\myBundle\Entity\civility 
 */
public function getcivility()
{
    return $this->civility;
}

/**
 * Get accCip
 *
 * @return \Doctrine\Common\Collections\ArrayCollection;
 *
 */
public function getAccCip(){
    return $this->accCip;
}

/**
 * Add accCip
 *
 * @param AccCip $accCip;
 * 
 * @return Person
 *
 */

  public function addAccCip(AccCip $accCip)
  {
    $this->accCip[] = $accCip;
    $accCip->setPerson($this);
    return $this;
  }

  /**
   * Remove accCip
   *
   * @param AccCip $accCip;
   *
   *
   */

  public function removeAccCip(AccCip $accCip)
  {
    $this->accCip->removeElement($accCip);
  }

  /**
   * Get cartes
   *
   * @return \Doctrine\Common\Collections\ArrayCollection
   *
   */
  public function getCartes(){
    return $this->cartes;
  }

  /**
   * Add carte
   *
   * @param Carte $carte;
   *
   * @return Person
   *
   */

  public function addCarte(Carte $carte)
  {
    $this->cartes[] = $carte;
    $carte->setPerson($this);
    return $this;
  }

  /**
   * Remove carte
   *
   * @param Carte $carte;
   *
   *
   */

  public function removeCarte(Carte $carte)
  {
    $this->cartes->removeElement($carte);
  }

  /**
   * Has carte
   * 
   * @return boolean
   * 
   */

  public function hasCarte()
  {
    return $this->cartes->count()!=0;
  }

  /**
   * Get panier
   *
   * @return \Doctrine\Common\Collections\ArrayCollection
   *
   */
  public function getPanier(){
    return $this->panier;
  }

  /**
   * Add panier
   *
   * @param Panier $panier;
   *
   * @return Person
   *
   */

  public function addPanier(Panier $panier)
  {
    $this->panier[] = $panier;
    $panier->setPerson($this);
    return $this;
  }

  /**
   * Remove panier
   *
   * @param Panier $panier;
   *
   *
   */

  public function removePanier(Panier $panier)
  {
    $this->panier->removeElement($panier);
  }

  /**
   * Get Somme Panier
   * 
   * @return float
   * 
   */

  public function getSommePanier()
  {
    $somme=0;
    foreach ($this->panier as $item){
        $somme+=$item->getMontant();
    }
    return $somme;
  }

  /**
   * Get transactions
   *
   * @return \Doctrine\Common\Collections\ArrayCollection
   *
   */
  public function getTransactions(){
    return $this->transactions;
  }

  /**
   * Add transaction
   *
   * @param TransactionPaybox $transaction;
   *
   * @return Person
   *
   */

  public function addTransaction(TransactionPaybox $transaction)
  {
    $this->transactions[] = $transaction;
    $transaction->setPerson($this);
    return $this;
  }

  /**
   * Remove transaction
   *
   * @param TransactionPaybox $transaction;
   *
   *
   */

  public function removeTransaction(TransactionPaybox $transaction)
  {
    $this->transactions->removeElement($transaction);
  }

  /**
   * Get adresses
   *
   * @return \Doctrine\Common\Collections\ArrayCollection
   *
   */
  public function getAdresses(){
    return $this->adresses;
  }


  /**
   * Add Adresse
   *
   * @param my\myBundle\Entity\Adresse $adresse;
   *
   * @return Person
   *
   */

  public function addAdresse(Adresse $adresse)
  {
    $this->adresses[] = $adresse;
    $adresse->setPerson($this);
    return $this;
  }

  /**
   * Remove adresses
   *
   * @param my\myBundle\Entity\Adresse $adresse;
   *
   *
   */

  public function removeAdresse(Adresse $adresse)
  {
    $this->adresses->removeElement($adresse);
  }

}

SQL:

CREATE TABLE "MYDB"."PERSON" 
(   "NO_PERSON" NUMBER(8,0), 
"COD_CIV" VARCHAR2(1 BYTE), 
"FIRST_NAME" VARCHAR2(30 BYTE), 
"USUAL_NAME" VARCHAR2(30 BYTE), 
"LAST_NAME" VARCHAR2(20 BYTE), 
"BIRTH_DATE" DATE, 
"COMMENT" VARCHAR2(300 BYTE), 
"C_USER_CREATION" VARCHAR2(30 BYTE), 
"DATE_CREATION" DATE, 
"C_USER_MODIFICATION" VARCHAR2(30 BYTE), 
"DATE_MODIFICATION" DATE, 
"EMAIL" VARCHAR2(100 BYTE), 
"ID_RH" NUMBER(8,0), 
)

編集: いくつかの詳細情報。最近、日付を実際の型の日付に変更しました (以前のバージョンでは「文字列」だったため (現時点では私は開発者ではありませんでした)。doctrine がエンティティを作成しようとすると、次の例外がスローされます:

Could not convert database value "08/07/92" to Doctrine Type date. Expected format: Y-m-d 00:00:00 

データベースの日付は、実際には「日付」SQL の型です。

4

1 に答える 1

0

値リストの日付のそれぞれの列を次のように変更すると、おそらく次のようになります。

to_date(?, 'Y-m_d 00:00:00')

これについては本当によくわかりません。私の頭に浮かんだちょっとした考え。

于 2013-05-13T14:59:13.180 に答える