2012-04-02 4 views
0

을 확인합니다. 양식을 만들려면 인스턴스 하나의 매개 변수가 필요합니다. 그러나 그를 유지할 필요는 없습니다. 나는 오류를 가지고> 플러시 $ 보하기를 호출 할 때prePersist 내가이 클래스가 널 객체

그래서 .. :

A new entity was found through the relationship ...

는이 문제를 해결하기 위해 내가 넣어 캐스케이드 = { "계속"} 주석의 :

//Class Anthropometry 
... 
/** 
* 
* @ORM\OneToMany(targetEntity="Project\Bundle\Entity\Parameter", mappedBy="anthropometry", cascade={"persist"}) 
* 
*/ 
protected $parameter; 

그러나 지금, 내 데이터베이스에서 매개 변수는 'Data'= NULL 필드를 사용하여 유지됩니다.

필드가 계속 유지되기 전에 prePersist로 확인할 수 있습니까?

이와 비슷한?

//class Parameter 
/** 
* 
* @ORM\prePersist 
*/ 
public function prePersist(){ 
    if($this->getData() == NULL){ 
     return false; 
    } 
} 

Thx!

답변

0

작동하지만 (당신이 매개 변수를 지속 할 필요가 없기 때문에) 당신이 인체 측정을 ​​지속하기 전에 매개 변수를 설정 해제 시도 할 수 있다면 내가 확인하지 않았다

//class Anthropometry 
/** 
* @ORM\prePersist 
*/ 
public function prePersist() 
{ 
    if(!is_null($this->parameter) && $this->parameter->getData() == null){ 
     $this->parameter = null; 
    } 
} 
+0

I가 중지됩니다 개발하고 프로젝트를 잠시. 그러나 나는 이것이 효과가있을 것이라고 생각한다. 고마워!! – Munir