The accepted answer is correct, but I'd like to offer some additional suggestions that you might want to consider:
Mark your entity as read-only.
Make the constructor private so that only Doctrine can create instances.
/**
* @ORMEntity(readOnly=true)
* @ORMTable(name="your_view_table")
*/
class YourEntity {
private function __construct() {}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…