Skip to content

🐛 Self transation cannot be resolved. #489

@peldax

Description

@peldax

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

Hi,

I am getting a following error when persisting a self referencing entitiy, such as following:

#[Entity(database: 'main')]
class Catalogue
{
    #[Column(type: 'primary')]
    private int $id;

    #[RefersTo(target: self::class, nullable: true)]
    private ?self $catalogue = null;

    #[HasMany(target: self::class)]
    private array $catalogues = [];
}

Error message:

Cycle\ORM\Exception\TransactionException: Transaction can't be finished. Some relations can't be resolved:
Create new `catalogue`
 - catalogue.catalogues:catalogue (Cycle\ORM\Relation\ShadowBelongsTo)

It seems that the ORM is having trouble understanding the selfReferencing relation.

Version

- ORM 2.8
- PHP 8.3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions