Thursday 15 January 2015

grails - Filter GORM relations into DTO objects -


I have a very easy model built with GORM, let's go with @OneToMany with a class spell and a class child Relation says. The child class has a 'version' specialty. Models are mostly read because the ups and downs are very rare. I consider my guardian object to be a criteria query from the database and I get every relation with my children (anxious or lazy does not really matter). So at this time I have a parent with my children.

Depending on the 'version', according to some rules, now I have to dynamically filter some child object from the set of parent relations (example: if two children have the same name , Then only the latest version should be in the relationship set), to pass the upper layers, to get results for more detail (maybe accessing the database again).

I am evaluating 2 approvals:

1) A DTO approach I am creating a DTO filtering for which I do not need and I want to give my results to the DTO object I pass in upper layers.

2) Recover all, separate objects, filter and pass children, different objects in upper layers.

3) Certain filter capabilities that I do not know, which can filter relationships with any attribute or some criteria

I think the first one is more secure, the database is different , DOTO objects can be modified without the risk of accidentally preventing exceptions when modifying goram units; But I would like to know if I am right and what are the recommendations when I come near a layered app that needs to be modified before returning the objects / units to the upper layers.

I'm going to become a simple Uni-डायरे রিসেশন্স & lt; - criteria :

  def list = Ownee.withCriteria {estimates {max 'version' group property 'name'} eq 'owner', owner}  

No comments:

Post a Comment