Predicate Generator

Posts   
 
    
ivog
User
Posts: 2
Joined: 24-Jun-2005
# Posted on: 24-Jun-2005 16:22:00   

Otis,

Have you ever thought about a predicatecode generator functionality which generates 'predicatecode' based on a given sql statement?

It must be a common task to convert sql to 'predicatecode', especially when you want to start using llblgen in an existing application with existing sqlstatements. It seems to me that that could be automated by looking at the sqlstatement and the schema.

If i think about it some more... llblgen could also interpret sql dynamically or am i talking nonsense here? I'm a bit new to llblgen pro...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Jun-2005 17:49:16   

It's very hard to write a converter for that, as the focus of SQL is on sets of field entries, but the focus of the predicates is on specifying filters so a subset of the complete set of objects is returned.

So instead of focussing on SQL, take a step back and define which entities you want to read, e.g.: which filter you should define to read the entities you want to load.

Then build that filter using predicates, by taking into account that each clause in the where section of a SQL statement, like Foo='10', is called a predicate. So by knowing that, you can go back to the manual and for example in the how-do-I section, check for each predicate class if your SQL predicate matches it and thus how to formulate it into code. That should give you a lot of the predicate filters you've to write.

Furthermore, because you now have an object model, you can use that to retrieve entities as well. For example if you have a Customer entity loaded, you can use that customer object to fetch its orders, without specifying any filters. In selfservicing, you can utilize lazy loading: customer.Orders, in Adapter, you can ask the customer object to formulate the filter for you: customer.GetRelationInfoOrders().

You can also fetch a graph in one go, using prefetch paths. For example 10 customers, their orders and order detail objects. This is a path: customer - order - order details. By constructing such a prefetch path, you can then order the generated code to fetch your 10 customers and at the same time their orders and order detail objects by specifying that prefetch path.

Frans Bouma | Lead developer LLBLGen Pro
ivog
User
Posts: 2
Joined: 24-Jun-2005
# Posted on: 27-Jun-2005 09:20:11   

ok thanks, i guess i just have to get into llblgen some more

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 27-Jun-2005 10:38:38   

It's a little bit of a learning curve. Please check out the how-do-I section in the documentation, which should get you started on some of the topics you will run into a lot.

Also, don't hesitate to ask how to do certain things. To learn things quickly, it's of course key that you try some things yourself first, but if you get stuck, it's often a small thing to get you going again, so ask freely, post the code you tried and I'll try to help you get going again a.s.a.p.

Also use the search on this forum. A lot of the questions people have are already answered before, it might be you can find the answer quickly simple_smile . THe forum was re-indexed yesterday with a much less strict noise word list, so searching should be much easier now simple_smile .

Frans Bouma | Lead developer LLBLGen Pro