ORM override? findAllWhere does not use my service model?

Hi,

getting to grips with ORM and ColdBox. something I don't understand. I
am trying to do everything via my service in my model however I have
an issue with this I wrote...

  void function checkCredentials(event) output=false{
    var rc = event.getCollection();
    rc.ouserbean = userService.new();//new object
    populateModel(rc.ouserbean);//populate object from scope

    rc.userfound =
userService.findAllWhere(user_name='rc.ouserbean.getuser_name()');

its works but I have 2 issues with this

1) findAllWhere, is this CF9 ORM as I don't need the function in my
service to work. "it just works!" I want to hit my service first how
do I do that? adding the function findAllWhere to my service does
nothing

2) why populating my model from the url scope I dont pass it as a
whole, should I not?

and help thanks :slight_smile:

What is this userService you talk about? A coldbox ORM entity service or a custom one?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

userService its my own, I am using the base BaseORMService.cfc also as
it needed right? findAllWhere is a CB thing from what I am reading not
CF9 ORM right?

login.cfc....

component extends="coldbox.system.EventHandler" output="false"{
  property name="userService" inject="entityService:user";

do i need to add the following to my login.cfc also?
property name="ORMService" inject="coldbox:plugin:ORMService";

hi,
its like this...

    rc.userfound = userService.countWhere(entityName="user",
user_name="#rc.ouserbean.getuser_name()#",
    user_password="#rc.ouserbean.getuser_password()#",
    user_active=true);

countWhere is not in my userService.cfc so where and how does it
inherit it? as my own userService.cfc is access remotely by a asp.NET
app i have I want countWhere function to be in my own service
otherwise my other app can not accees it.

:P) just trying to get my head around this having some free time this
week and its on my list to learn.

Ok, you are on the right track but you are injecting the wrong CFC.

This →
property name=“userService” inject=“entityService:user”;

Is injecting a virtual service layer object based on the User entity and the base ORM service that ColdBox provides. This gives you a very nice generic service layer binded to the User entity.

The UserService you created does nothing as it is never injected in your handlers or used. Do you get it?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Thanks for responding back Luis,

property name="userService" inject="entityService:user";

ok so.... entityService is a virtual service layer thats injected with
my "user" object and is made available in my login.cfc handler, by
using the above code, thats really cool it i got that right.

but how do I go about overriding, decorating some functions of this
virtual layer i.e. use my own service layer that still extends/
inherits CB ORM and/or the virtual layer. I want my service layer to
be open remotely/exposed, I want to write my own custom functions or I
may want to extend overwrite a few entityService functions. I want all
my service layers organised, one for login one for security, one for
campaigns etc.

is this possible?

Is injecting a virtual service layer object based on the User entity
and the
base ORM service that ColdBox provides. This gives you a very nice
generic
service layer binded to the User entity.

right, i think I am starting to understand now.

in my handler I would just inject my own userService

property name="userService" inject;

now I dont won't to duplicate the function in CB virtual layer thats
bad code, so I would want to extend my own userService.cfc like so...

component extends="coldbox.system.orm.hibernate.VirtualEntityService"{

  public any function init(){
      super.init( "user", true);
      return this;
  }

anything wrong with this?

You got it!!

That’s absolotuely right. The base ORM service follows the template pattern. This way you can template it out and create more concrete based classes but you get ALL the functionality there already. I have definitely seen an incredible boost in my development time as the base service layers for ORM in ColdBox take me about 85 to 90% there.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

I'm really looking forward to the EntityService working with Railo and
its Hibernate implementation. Will be totally slick.

Judah

cool, thanks Luis.