Doctrine Project

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Doctrine 2 - ORM
  • Doctrine 2 - ORM
  • DDC-209 Add the notion of read-only entities
  • DDC-692

Read-only entities

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Sub-task Sub-task
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.1
  • Component/s: ORM
  • Security Level: All
  • Labels:
    None

Description

It should be possible to mark an entity class as read-only so that it is never considered for change-tracking after it has been initially inserted into the database.

This feature is mainly a flush performance tweak to avoid checking objects for changes which can never actually change.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
  • Source
Hide
Permalink
Christian Heinrich added a comment - 13/Sep/10 7:37 AM

Roman, could you point out how exactly you expect this to work?

I mean, when you create a new entity and persist it, you surely need to track updates to the entity-to-be-persisted.

Additionally, what about entities that are expected to be updated only in one place, like a service. Should there be a possibility to enforce updating?

Show
Christian Heinrich added a comment - 13/Sep/10 7:37 AM Roman, could you point out how exactly you expect this to work? I mean, when you create a new entity and persist it, you surely need to track updates to the entity-to-be-persisted. Additionally, what about entities that are expected to be updated only in one place, like a service. Should there be a possibility to enforce updating?
Hide
Permalink
Marc Hodgins added a comment - 13/Sep/10 3:16 PM - edited

For us, I see a use case for summary tables (i.e. Post and PostViews – a roll up of log data into computed "most popular", "most commented", views per day/week/month, etc). The data is generated outside of Doctrine (i.e. directly via DBAL, or stored procedures) but we still want to define the relationships of other entities to this data so we can access it on a read-only basis in DQL and the object graph. We would flag these as read-only as there is no need for change-tracking. Example:

/** @Entity */
class Post {
    /** @OneToMany(targetEntity="PostViews" ...) */
    protected $views;
}
/** @Entity @ReadOnly */
class PostViews { /* summary table computed via stored procedure */

   public function __construct() { throw new \Exception('Entity is read only'); }

    /** @Column */
    protected $period; // day, week, month, year, etc.

   /** @Column */
   protected $viewCount;
}

Regarding Roman's description of persist-only and then no updates, isn't this more like @PersistOnly rather than @ReadOnly? Or you could generalize this further with a tag like @AllowedActions={"persist", "update", "delete"} ?

/** @Entity @PersistOnly */
class A {
    /** @Column */
   protected $foo;
   
  public function __construct($foo) {
     $this->foo = $foo;
  }

  public function getFoo() {
    return $this->foo;
  }
}

Is this what you have in mind Roman?

Show
Marc Hodgins added a comment - 13/Sep/10 3:16 PM - edited For us, I see a use case for summary tables (i.e. Post and PostViews – a roll up of log data into computed "most popular", "most commented", views per day/week/month, etc). The data is generated outside of Doctrine (i.e. directly via DBAL, or stored procedures) but we still want to define the relationships of other entities to this data so we can access it on a read-only basis in DQL and the object graph. We would flag these as read-only as there is no need for change-tracking. Example: /** @Entity */ class Post { /** @OneToMany(targetEntity= "PostViews" ...) */ protected $views; } /** @Entity @ReadOnly */ class PostViews { /* summary table computed via stored procedure */ public function __construct() { throw new \Exception('Entity is read only'); } /** @Column */ protected $period; // day, week, month, year, etc. /** @Column */ protected $viewCount; } Regarding Roman's description of persist-only and then no updates, isn't this more like @PersistOnly rather than @ReadOnly? Or you could generalize this further with a tag like @AllowedActions={"persist", "update", "delete"} ? /** @Entity @PersistOnly */ class A { /** @Column */ protected $foo; public function __construct($foo) { $ this ->foo = $foo; } public function getFoo() { return $ this ->foo; } } Is this what you have in mind Roman?
Hide
Permalink
Benjamin Eberlei added a comment - 29/Mar/11 2:18 PM

Implemented.

Show
Benjamin Eberlei added a comment - 29/Mar/11 2:18 PM Implemented.

People

  • Assignee:
    Benjamin Eberlei
    Reporter:
    Roman S. Borschel
Vote (0)
Watch (1)

Dates

  • Created:
    15/Jul/10 10:19 AM
    Updated:
    29/Mar/11 2:18 PM
    Resolved:
    29/Mar/11 2:18 PM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Doctrine Project. Try JIRA - bug tracking software for your team.