|
(sorry if this is a
duplicate, last mail got bounced) Hi, I use the same method, I
normally write my objects with a loadById() method which only sets the objects
id if a record is found. So I can then check to see if the id is zero, or I
use isvalid(‘uuid’ object.getId()) if it’s a uuid. My personal
preference would have been to seen load() return true or false, but sounds like
that’s not possible. As an alternative if the load() method fails to
actually find a valid record, could it not reset the object to its default
values, afterall if your calling load() your expecting any values to be
populated. Cheers, Chris From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kurt Wiersma I use a similar to
technique to Jared where I check to see if my enties' ID is zero and if so
assume that a record was not found. It has seemed to work well for us so far,
but perhaps it might not work for others. On 2/2/06, Jared
Rypka-Hauer <[EMAIL PROTECTED]>
wrote: Doug, Until I've spent more time with Reactor, you'll have to forgive me for
speaking from an ARF perspective. Give me time, I'll get there. ;) What I typically do is: <cfset MyRecord =
RecordFactory.getRecord("my.path.to.Record")> <cfset MyRecord.read(10)> <cfif myRecord.getRecordId()> <cf_do_something /> </cfif> If I've got data in the
object, but no ID, I know it has been populated but not persisted yet. If I have no other data
and no ID, I know the object is fresh and blank. So... could the delete()
method automatically set the primary key field for the table to "" in
the object? Sure, fine, leave the rest of the data alone, but if you set the
pkey to empty you'll still know that the data it carries is not in the database
at this time. I like the idea of having a hasData() method (data in every field
or a list of column names to check?). How about a getLastOperation() that
returns "READ", "WRITE", "DELETE" etc. That way: <cfif hasData() and
getLastOperation() is "READ"> <cfreturn
"Mustabeen a good read" /> </cfif> <cfif hasData() and getLastOperation() is "WRITE" and
getTableId()> <cfreturn "Mustabeen a good write" /> </cfif> <cfif NOT getTableId() and getLastOperation() is
"DELETE"> <cfreturn "Mustabeen deleted!" /> </cfif> Just something to think about. Thanks, J ------------------------------------------------ Jared C. Rypka-Hauer Continuum Media Group LLC Member, Team Macromedia - ColdFusion "That which does not kill me makes me
stranger." - Yonah Schmeidler On Feb 1, 2006, at 8:04 PM, Doug Hughes wrote:
João - I've been thinking about this, but I don't have a good answer
at the moment. My natural inclination would be to have the load method
return true of false to indicate if the record was loaded, but recent updates
won't allow for that. I would also consider having the DAO's read method
thrown an error if 0 rows are returned (in the same way that more than 1 throws
an error too)... but that smells funny. I also thought about adding a method to either the TO or
Record. Something like "hasBeenLoaded". This method would
return true if a record had been loaded. It would return false when a
record had not been loaded. The thing is that there are lots of cases
where that could get out sync. For example: When you create a record, before you load anything "hasBeenLoaded"
returns false. Now, if you load something it returns true. But,
what if you delete the record. Should that still return true? Or,
if you simply create a record and start populating it... I assume "hasBeenLoaded"
would return false still, but it's valid data. And, let's say you then
save it... has it been loaded? Or is hasBeenLoaded still false? If right now I needed to deal with this I think I'd override
the properties value in my TO to a 0 value or 00000-00000-0000-000 (or whatever).
That could be tested for at least... but you'd have to work arround that in
your application. Anyone have any better suggestions? Doug From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
On Behalf Of João Fernandes Doug do you have any info about this? João Fernandes Secção de Desenvolvimento Departamento de Informática From: [EMAIL PROTECTED] [ mailto:[EMAIL PROTECTED]]
On Behalf Of João Fernandes Doug, How can we know if a record was really loaded? Table UUID uniqueidentifier LdapUser varchar(20) LdapDate varchar(20) If I use UserRecord.setLdapUser(someval) UserRecord.setLdapDate(someotherval) UserRecord.load("ldapUser,LdapDate") I get the UUID created instantly and I don't know if this
record really exists or was created at the moment. Regards, João Fernandes Secção de Desenvolvimento Departamento de Informática From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED].net] On Behalf Of Doug Hughes Michael, I added a new feature to support this requirement. You can still continue to use Reactor the way you have been,
IE: loading via PK values. However, now you can load by non PK values, but
you need to specify the field names when you call load. IE: <!---
Setup PersonRecord for entry ---> You can specify more than one field if you want in a comma
separated list. If you provide PK values you don't need to provide list
of fields to the load method (which is how it currently works). To start using this feature, delete all of your project files
from /reactor/project. This update changes some of how the core files are
generated. Doug Hughes From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
On Behalf Of Michael Lantz OK, on to bigger and better things for today! So, I was just working on something and I have a question.
Check out this code: <!---
Setup PersonRecord for entry ---> The EmailAddress field is a UNIQUE constraint on the Person
table. The PK is PersonID. What I want to do is set an EmailAddress and then load the
record. This does not seem to be working. So, is it not setup to
work that way, or is there something else wrong here? Thanks, Michael
|

