Mapeo de datos ORM a objetos

A inhouse ORM has been developed using stored procedures to get the data to populate individual objects in a complex hierarchy. We have moved from a stored procedures for each mapping action to dynamic sql which is built up at runtime and executed which should increase functionality and performance. Each class has its own mapping code stating property to db column mapping, table, cardinality etc.

My issue is that due to complexities of the object model, an object being built by the ORM/mapper code will call potentially more data than is needed and thus hamper performance.

Is this an issue with the object model or the ORM or both?

Could anybody suggest a design pattern/idea to help administer this issue?

My first thoughts were that we should have extra functionality in out mapping classes to control the depth of the data retrieved but how could this be achieved cleanly i don't know. any ideas or thought on this subject will be greatly recieved.

preguntado el 24 de agosto de 12 a las 10:08

By more data, do you mean the relational data of an object, which you store as a property (single row or multiple rows?) -

I hope this makes sense but by more data, i mean that the mapping class and subsequent child mapping classes build a single sql statement based on the object hierarchy which may mean that you get 100s of rows of data in a single call. which is returned and mapped back to a single object with 100s of children as an example. The problem lies with each object having its own mapping so that class A will then use the mappings for class b and so on.. to class z. When i may only need the class a and b.The issue lies with performance and the posibility of recursion. -

I would go with the lazy fetching as Vikdor suggested, also take a look at the Repository Pattern and dapper-dot-net -

This problem is solved very well by ORMs that already exist and while building a custom ORM is fine, this problem is not really easy to solve in your custom ORM so you should really considering using an existing ORM rather than continue down this path of recreating NHibernate, etc. from scratch. -

1 Respuestas

ORMs like Hibernate deal with this scenario using "Lazy Fetch" strategy where the object associations to any depth are maintained as is, but the objects in the hierarchy are fetched on demand when they are accessed for the first time. You might want to look at Patrón de proxy to get an idea of how this could be done.

Respondido 24 ago 12, 10:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.