Yes, if you wish, you can combine ORM and pure SQL in a project to maximize efficiency: use ORM for rapid development and simple maintenance, and pure SQL for complex queries and performance optimization. This gives you the best of both worlds: productivity and detailed control as needed.
Some ORMs have entity tracking and let's say you update via raw query an entity that's already tracked, your tracking object won't be updated and this cause a lot of confusion and debugging pain. That's why I would avoid combining both.
I understand your concerns, GosuTeacher. However, many modern ORMs allow for the execution of custom SQL queries while still maintaining entity tracking and management. This offers us flexibility for complex cases without losing the advantages of the ORM. The key is to use this feature wisely, ensuring that complex operations integrate well with the overall data management. This way, we can enjoy the best of both worlds: the simplicity of the ORM and the precision of pure SQL for specific needs.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
And can I use both methods in the same project?
Yes, if you wish, you can combine ORM and pure SQL in a project to maximize efficiency: use ORM for rapid development and simple maintenance, and pure SQL for complex queries and performance optimization. This gives you the best of both worlds: productivity and detailed control as needed.
Some ORMs have entity tracking and let's say you update via raw query an entity that's already tracked, your tracking object won't be updated and this cause a lot of confusion and debugging pain. That's why I would avoid combining both.
I understand your concerns, GosuTeacher. However, many modern ORMs allow for the execution of custom SQL queries while still maintaining entity tracking and management. This offers us flexibility for complex cases without losing the advantages of the ORM. The key is to use this feature wisely, ensuring that complex operations integrate well with the overall data management. This way, we can enjoy the best of both worlds: the simplicity of the ORM and the precision of pure SQL for specific needs.