开发者

ORM for non-destructive system?

I don't know if there is a spe开发者_如何转开发cific name for this, but I am designing an application backed by a database in which rows need to be immutable (not sure if that term applies here, but it is the closest to describing what I need). That is, instead of changing the data stored in a row, a new row would be inserted with the same id but a different primary key. There would be some metadata stored with row that would indicate which is the most current row for that id, and whether the record with that id has been "deleted". I would like to use an ORM in which I could use normal insert, update, delete statements, but would do all that in the background. Since I don't know what terminology to use, I am having a hard time finding a solution using the great, all-knowing Google. Does an ORM like this exist, or would I have to build one / modify an existing one? Any tips are appreciated.


You could use any ORM that supports stored procedures, then write sprocs to perform the updates.


What you might be looking for is a temporal database pattern whereby saving each item creates a new version. The idea behind temporal databases is that you can essentally query the data as it was at a given date.


Maybe this might be asolution?

http://docs.jboss.org/envers/docs/index.html


The terminology for what your looking for is generally called Copy-on-write.

Ironically many databases like Postgresql (MVCC) and SqlServer (Snapshot) do some form of COW but for performance and ACID reasons.

From what I gather your probably looking for version control characteristics and while I do not know of any ORM or RDBMS that supports such behavior there are many content repositories that do. An example would be a JCR implementation (JSR 170) such as JackRabbit.

Otherwise I recommend you look how Wiki software works that uses an RDBMS (generally two columns indices with an id and version column).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜