Hi Garrett,
I'd be surprised if that is the issue. I can't see your
getHighSchoolBean() method, but if it's calling
getBean("highschoolbean") (or getTransient("highschoolbean") (either
is fine) then it should work just fine as LW *always* does a new
create object for transients. I'd check you haven't elsewhere done an
addSingleton("highschoolbean") (don't what would happen but it could
break things) and I'd also double check the query, etc. Also, feel
free to look at the lightwire code - if doesn't do much so it's pretty
easy to understand and debug.
I separately notice you're manually calling init on your bean - but
LightWire also calls that, so I'd consider having a separate load
method for your bean for loading up the data.
If you *really* think the problem is in lightwire, create the simplest
possible test case where you have code something like:
<cfscript>
HSBean1 = getBean("highschoolbean").load(title="title1");
HSBean2 = getBean("highschoolbean").load(title="title2");
</cfscript>
HSBean1 Title = #HSBean1.getTitle()#<br/>
HSBean2 Title = #HSBean2.getTitle()#<br/>
If that code DOES break, post sample code to the list including a copy
of a bean with a load method and a getTitle method and I'll test, but
I'd be pretty surprised if it did.
Best Wishes.
Peter
On Sep 14, 2009, at 10:58 AM, garrettjohnson wrote:
>
> I am trying out lightwire for the first time and I am noticing a small
> problem when it comes to returning an array of beans from my DAO. It
> seems that its my array is an array of the same exact bean, rather
> then multiple instances of my bean.
>
> I have the following in my bean config:
>
> addSingleton("educationService", "educationService");
> addSingleton("educationDAO", "educationDAO");
> addSingleton("educationGateway", "educationGateway");
> addTransient("highschool", "highschoolBean");
>
> addSetterDependency("educationDAO", "highschoolBean");
> addConstructorDependency("educationService", "educationGateway");
> addConstructorDependency("educationService", "educationDAO");
>
> then in my DAO layer:
>
> <cffunction name="read" access="public" returntype="any"
> output="false" hint="I return a populated an arrray of highschool
> objects">
> <cfargument name="ID" type="numeric" required="true" />
>
> <cfset var q = "" />
> <cfset var objects = arrayNew(1) />
>
> <cfquery datasource="#getSettings().getDatasource()#"
> name="q">
> <!--- some query --->
> </cfquery>
> <!--- populate highschool Beans --->
> <cfloop query="q">
> <cfset objects[q.currentRow] = getHighschoolBean().init
> (q.highschoolID, q.graduationDate, q.highschoolGPA,
> q.highschoolClassRank, q.highschoolClassSize, q.highschoolPercentile,
> q.dateUpdated) />
> </cfloop>
>
> <cfreturn objects />
> </cffunction>
>
>
> Now I do not get an error or anything but if my query return 3
> records, lets say Foo high, Woo high, Moo high... then when I call my
> code in my cfm template.... loop array... #school.getName()#..... It
> will return Moo high 3 times, rather then what it should really be
> doing!
>
>
> Any thoughts?
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---