Include Template for ConcurrencyPredicateFactoryToUse?

Posts   
 
    
alexk
User
Posts: 19
Joined: 14-Sep-2005
# Posted on: 23-Dec-2005 10:20:17   

The 2 postings below from early this year indicated that an include template would be created to faciliate the setting of ConcurrencyPredicateFactoryToUse for all entities. I have a set of entities with a parent-child-grandchild relationship. For those objects, I need to set that property to enable optimistic locking for updates & deletes during recursive DataAccessAdapter and UnitOfWork2 saves. Does that include template exist now, and if so what is its name?

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2049&HighLight=1 http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2316&HighLight=1

As usual, thank you very much!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 24-Dec-2005 10:03:02   

I don't see any claim that such a template would be included, also because it's very application specific so not really an option for a template for us to ship with llblgen pro, you have write that little template yourself simple_smile . You should use the last post in the second thread you posted to get started. Did you try that and run into a problem somewhere? If so, could you elaborate a bit what the problem was?

Frans Bouma | Lead developer LLBLGen Pro
alexk
User
Posts: 19
Joined: 14-Sep-2005
# Posted on: 25-Dec-2005 10:19:30   

I don't see any claim that such a template would be included

I may have very well misinterpreted! From the 1st link,

Entity's InitClass methods will be split up into an include template pretty soon which will make it possible to 'inject' code at instantiation time for an entity which then allows to create an instance of a concurrencypredicatefactory class without worries.

From the 2nd link,

The init method of the class doesn't yet include an include template, which should be the case. This is added soon.

I thought by those statements that there would be an include template where we could put custom code that would be executed during object construction. So, there I could assign ConcurrencyPredicateFactoryToUse to my implementation of IConcurrencyPredicateFactory.

also because it's very application specific so not really an option for a template for us to ship with llblgen pro, you have write that little template yourself

If that include template did exist, I'd just imagine it to be blank by default, and then we could customize with whatever code we wanted. In my case, it would have been something like

this.ConcurrencyPredicateFactoryToUse = FooConcurrencyPredicateFactory.Instance;

You should use the last post in the second thread you posted to get started. Did you try that and run into a problem somewhere? If so, could you elaborate a bit what the problem was?

I didn't want to go with the solution in that 2nd thread because it seems to require that I use the factory method instead of class constructors. e.g., instead of "new FooEntity()", I'd have to use "GeneralEntityFactory.Create(EntityType.FooEntity)". More importantly, I don't know how to apply custom factories when I read in an object graph using prefetch paths.

alexk
User
Posts: 19
Joined: 14-Sep-2005
# Posted on: 27-Dec-2005 20:58:41   

My goal is just to set ConcurrencyPredicateFactoryToUse for all objects retrieved. It doesn't matter if there isn't a template. Is manually traversing the object graph the only solution?

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 29-Dec-2005 09:15:07   

alexk wrote:

My goal is just to set ConcurrencyPredicateFactoryToUse for all objects retrieved. It doesn't matter if there isn't a template. Is manually traversing the object graph the only solution?

Thanks!

No not at all, it's very simple, create an include template in where you add the concurrencypredicatefactory instance to the property of the entity. Please see this thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2284

for a guideline (it's about a different hting, but creates an include template as well). Also see the 'adding your own code to the generated code' section in the manual as it also discusses how to create an include template. You can use a TDL template (.template) or a .lpt template as include template, whatever you prefer simple_smile

Frans Bouma | Lead developer LLBLGen Pro
alexk
User
Posts: 19
Joined: 14-Sep-2005
# Posted on: 31-Dec-2005 18:12:52   

Wow, very neat! I didn't know we could create our own include templates. I had thought we could only use the predefined template ID's.

You suggested reading the help section "Adding your own code to the generated classes". I had skimmed that before but totally missed template ID "Custom_EntityInitializationTemplate". I'm sorry for that. flushed That must be the template ID you had written that you'd create in the aforementioned two posts.

I see that code in that would be executed at the end of InitClassEmpty(). Is that method always called when retrieving persisted objects, including when part of a prefetch path? If so, then should I put my ConcurrencyPredicateFactoryToUse assignment in that include template?

Thanks for all your help, Otis. It is very much appreciated.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 02-Jan-2006 10:43:48   

alexk wrote:

Wow, very neat! I didn't know we could create our own include templates. I had thought we could only use the predefined template ID's.

simple_smile In v2.0 we will greatly enhance the way to utilize these features as a lot of customers don't really know they're there or find it too cumbersome to use them.

I see that code in that would be executed at the end of InitClassEmpty(). Is that method always called when retrieving persisted objects, including when part of a prefetch path? If so, then should I put my ConcurrencyPredicateFactoryToUse assignment in that include template?

It is always called. You can place your assignment there.

Frans Bouma | Lead developer LLBLGen Pro