开发者

mapping view using castle activerecord, exception on primary key

开发者 https://www.devze.com 2023-02-13 03:10 出处:网络
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

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

精彩评论

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