On Thu, Apr 11, 2002 at 01:11:00PM -0700, James A. Hillyerd wrote:
> I discovered that you can add defaultJavaType="object" to your
> <database> definition, and all the primitives will become objects.
That would help, but woudln't solve the problem I was having - the
generated peer classes still attempt to build a criteria using all the
attributes, and this fails if the attributes are null.
I've had a look at the Peer.vm template, but don't know any Velocity
which limited my efforts. I've botched together a patch to Peer.vm
that works for me with James's defaultJavaType work around (diff at
the end of this mail), but I can't help feeling that it would be more
elegant to change the semantics of Criteria.add such that add(COLUMN,
null); was equivalent to add(COLUMN, null, Criteria.ISNULL).
jim
diff for Peer.vm. HEALTH WARNING: Only works if the defaultJavaType attribute of
'database' in your 'XXX-schema.xml' file is set to 'object'.
797,798c797,798
< if ( !obj.isNew() )
< #end
---
> if ( !obj.isNew() )
> {
799a800,811
> }
> #else
> if ( obj.get${cfc}() == null )
> {
> Object o = null;
> criteria.add( $cup, o, Criteria.ISNULL );
> }
> else
> {
> criteria.add( $cup, obj.get${cfc}() );
> }
> #end
>
> -james
>
> On Thu, 2002-04-11 at 11:41, David Sean Taylor wrote:
> > Jim,
> >
> > Did you ever get an answer or solution to your question?
> > Also saw that James A. Hillyerd's message 'Null values with Torque'
> > seems to be unresolved.
> >
> > Is this a bug?
> > Does anyone have a patch....
> >
> > David
> >
> > >
> > > Hi,
> > >
> > > I've been using Torque for about a week, working through the
> > > tutorial and a couple of tester programs, and came across a
> > > problem when I started to use the framework in anger. It's
> > > likely that I just haven't understood the thrust of what's
> > > going on; none of this is in any way criticism.
> > >
> > > Is it possible to have null valued attributes in Torque
> > > created objects? I've been getting a java.lang.VerifyError
> > > which I traced to the BaseXXXPeer class (generated from
> > > Peer.vm). The buildCriteria method assumes that all values
> > > are non-null, given that it's illegal to add a null value to
> > > a Hashtable (which Criteria extends).
> > >
> > > So; is it a basic condition of Torque that all attributes
> > > should be initialized and non-null? If so, wouldn't it be
> > > better to add default value initialization to the generated SQL?
> > >
> > > Thanks,
> > > Jim Downing
> > > [EMAIL PROTECTED]
> > >
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>