Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

WcmUsePojo Vs Sling Models

Avatar

Level 4

we are updating our current Project to 6.3, If some body can say which one is the best approach.

WcmUsePojo or Sling Models, it will be great help.

1 Accepted Solution

Avatar

Correct answer by
Level 3

There is no the best solution for that. It depends on many various things smacdonald2008​ wrote already (with massive exhausing explanation). Although tldr: using Sling Models coexist with using a lot of annotations (like JPA a little, at least for me) and Use classes are rather manual processing from a resource to specific class. Moreover, and forgive my ignorance, Sling Models are using (100% sure) adaptTo method and I am not sure which mechanism Use classes are using (I think its some injections during HTL but I might be wrong). Personally I have got away from Use classes in favour of Sling Models but it was related to that I need mostly plain classes without any processing so essentially few fields with annotations and getters are doing their job well.

View solution in original post

4 Replies

Avatar

Correct answer by
Level 3

There is no the best solution for that. It depends on many various things smacdonald2008​ wrote already (with massive exhausing explanation). Although tldr: using Sling Models coexist with using a lot of annotations (like JPA a little, at least for me) and Use classes are rather manual processing from a resource to specific class. Moreover, and forgive my ignorance, Sling Models are using (100% sure) adaptTo method and I am not sure which mechanism Use classes are using (I think its some injections during HTL but I might be wrong). Personally I have got away from Use classes in favour of Sling Models but it was related to that I need mostly plain classes without any processing so essentially few fields with annotations and getters are doing their job well.

Avatar

Level 2

I recommend Sling Models because there are very restrictive test libraries that support WCMUsePojo. Sling Models FTW!