Stored procedures or OR mappers?

后端 未结 15 1264
天命终不由人
天命终不由人 2021-01-06 16:04

Which is better? Or use and OR mapper with SP\'s? If you have a system with SP\'s already, is an OR mapper worth it?

相关标签:
15条回答
  • 2021-01-06 17:06

    Definitely ORMs. More flexible, more portable (generally they tend to have portability built in). In case of slowness you may want to use caching or hand-tuned SQL in hot spots.

    Generally stored procedures have several problems with maintainability.

    • separate from application (so many changes have now to be made in two places)
    • generally harder to change
    • harder to put under version control
    • harder to make sure they're updated (deployment issues)
    • portability (already mentioned)
    0 讨论(0)
  • 2021-01-06 17:07

    This has been discussed at length on previous questions.

    What are the pros and cons to keeping SQL in Stored Procs versus Code

    0 讨论(0)
  • 2021-01-06 17:09

    They are not actually mutually exclusive, though to your point they usually are so.

    The advantage of using Object Relational mapping is that you can swap out data sources. Not only database structure, but you could use any data source. With advent web services / Service-oriented architecture / ESB's, in a larger corporation, it would be wise to consider having a higher level separation of concerns than what you could get in stored procedures. However, in smaller companies and in application that will never use a different data source, then SP's can fit the bill fine. And one last point, it is not necessary to use an OR mapper to get the abstraction. My former team had great success by simply using an adapter model using Spring.NET to plug-in the data source.

    0 讨论(0)
提交回复
热议问题