我正在尝试将 Code Igniter 与 Doctrine 2 集成。除了我无法保存一个对象的属性外,一切都运行良好。
这是一个引发奇怪错误的小代码片段
$account = $this->em->getRepository('Entities\Account')->findOneById($accountId);
$ofx = new \Entities\FinancialRecord();
$a = $accountCatDao->findByPayeeName("PETROCAN", $account);
ofx->setAccount($account);
$ofx->setAmount($b->getAmount());
$ofx->setDatePosted(new DateTime());
$ofx->setDateUser(new DateTime());
$ofx->setPayeeCity($b->getPayeeCity());
$ofx->setPayeeName($b->getPayeeName());
$ofx->setPayeeState($b->getPayeeState());
$ofx->setTransactionId($b->getTransactionId());
$ofx->setTransactionType($b->getTransactionType());
// FOLLOWING LINE CAUSING THE PROBLEM
$ofx->setCategory($a->getCategory());
$this->em->persist($ofx);
$this->em->flush();
抛出错误
Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'No mapping file found named 'Proxies.__CG__.Entities.Category.dcm.yml' for class 'Proxies\__CG__\Entities\Category'.' in /Users/yannlaviolette/Sites/finance/application/libraries/Doctrine/ORM/Mapping/MappingException.php on line 68
(!)
Doctrine\ORM\Mapping\MappingException: No mapping file found named 'Proxies.__CG__.Entities.Category.dcm.yml' for class 'Proxies\__CG__\Entities\Category'. in /Users/yannlaviolette/Sites/finance/application/libraries/Doctrine/ORM/Mapping/MappingException.php on line 68
我的映射对象
Entities\FinancialRecord:
type: entity
table: finance.financial_record
fields:
id:
id: true
type: bigint
nullable: false
generator:
strategy: SEQUENCE
transactionId:
type: string
length: 255
fixed: false
nullable: false
column: transaction_id
transactionType:
type: string
length: 10
fixed: false
nullable: false
column: transaction_type
datePosted:
type: datetimetz
nullable: false
column: date_posted
dateUser:
type: datetimetz
nullable: false
column: date_user
payeeName:
type: string
length: 255
fixed: false
nullable: false
column: payee_name
payeeCity:
type: string
length: 255
fixed: false
nullable: false
column: payee_city
payeeState:
type: string
length: 3
fixed: false
nullable: false
column: payee_state
amount:
type: decimal
nullable: false
manyToOne:
category:
targetEntity: Entities\Category
cascade: ["persist", "merge"]
account:
targetEntity: Entities\Account
cascade: ["persist", "merge"]
lifecycleCallbacks: { }
我真的没有想法。在这个问题上花了 2 天时间。有人可以帮我吗?
扬