开发者

mapping view using castle activerecord, exception on primary key

Using answer from this question, I'm trying to map my database view. But, it throw exception because I don't define any PrimaryKey on the mapping class (the view doesn't have any primary key). Do I need to use Compos开发者_开发技巧iteKey (this is not recommended, according to castle website) to solve this problem ? Or there is better solution ?


Quoting the docs:

Regular ActiveRecord types must have a primary key, a key that uniquely indentifies any row in a table. Single surrogate keys are favouvered over composite keys, but both are supported. When having control over the database schema, adding a surrogate primary key to the tables is the recommended way of implementing primary keys.

So add a simple primary key. If you can't, add a composite key.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜