mapping view using castle activerecord, exception on primary key

混江龙づ霸主 提交于 2019-12-25 00:29:51

问题


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 CompositeKey (this is not recommended, according to castle website) to solve this problem ? Or there is better solution ?


回答1:


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.



来源:https://stackoverflow.com/questions/5075804/mapping-view-using-castle-activerecord-exception-on-primary-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!