You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Jim Mackraz <ji...@mackraz.com> on 2001/11/03 07:46:48 UTC

standalone Torque and Oracle (NULL insert problem again)

I am using the recipe for standalone torque from Steve Davis (torque outside
turbine - detailed example (long))
http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg03639.html
[THANKS, Steve!]

The recipe includes building torque from cvs jakarta-turbine-torque, etc.
I checked out jakarta-turbine-torque tonight (2Nov2001) and did just that.

I'm using Steve's bookstore schema w/ two changes:
- remove app-data top-level tag.
- add idMethod="native" to all tables (I've tried the deprecated "sequence"
too, for grins)

Running his test program, I get the error: cannot insert NULL into
("AQUI1"."AUTHOR"."AUTHOR_ID")
(AUTHOR_ID is the autoincrement key)

----
I've done what I can to scour the mailing list (I have village-1.5.3-dev.jar
as per one posting).
I tried playing around w/ the source and jdb... couldn't figure out much.  I
don't have Village source; for one reason, because www.working-dogs.com is
not responding tonight.

I don't know where the sequence/insert is supposed to be composed anyway.
I did follow
http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04064.html
and see that Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
at line 767 of BasePeer.java is returning null...  but I can't figure out
what to do with his advice:

tMap.setSequenceInfo( insert HARD-CODED key information here );
I put his fragment in MapBuilder.vm and the generated code in
AuthorMapBuilder.java now looks like this:
     tMap.setSequenceInfo( getAuthor_Id() );
     tMap.addPrimaryKey ( getAuthor_Id(), new Integer(0) );

----
I saw this comment from Jason: "I don't know if you've been watching the
commits flying by."
in
http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04052.html
dated last Saturday, but I don't know if that's related to this.

I'd be happy to try to help, this weekend, in testing this small test app
against Oracle, if work is in progress.

=========================================

Additionally, perhaps some higher-level guidance would help me:
I'm trying to get torque to work standalone so that:
a) I can write standalone utilities against my object model/database
b) I can program against that same model in a servlet, under Tomcat, which
does NOT use Turbine.

Is (b) going to work?  I don't know Jack about Turbine, or Fulcrum, or
whatever... which is one reason I can't get involved with it now (I spent a
couple of days trying).

Thanks much,
  Jim Mackraz
  jim@mackraz.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: standalone Torque and Oracle (NULL insert problem again)

Posted by John McNally <jm...@collab.net>.
it is in TorqueObjectModelTask, and it should be in one or more of the
sql tasks as well.  This was needed even given the automatic pulling of
properties into the context as the property is named "database" and the
context key is "targetDatabase".

john mcnally

Jim Mackraz wrote:
> 
> A little followup:
> 
> In the standalone source tree, I see no occurence of setTargetDatabase()
> anywhere under: jakarta-turbine-torque/src
> 
> That would appear to be necessary to set $targetDatabase in any of the
> sundry Torque*Task contexts..
> 
> ----- Original Message -----
> From: "John McNally" <jm...@collab.net>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Sunday, November 04, 2001 9:36 AM
> Subject: Re: standalone Torque and Oracle (NULL insert problem again)
> 
> > Jim Mackraz wrote:
> > >
> > > I am using the recipe for standalone torque from Steve Davis (torque
> outside
> > > turbine - detailed example (long))
> > >
> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg03639.html
> > > [THANKS, Steve!]
> > >
> > > The recipe includes building torque from cvs jakarta-turbine-torque,
> etc.
> > > I checked out jakarta-turbine-torque tonight (2Nov2001) and did just
> that.
> > >
> > > I'm using Steve's bookstore schema w/ two changes:
> > > - remove app-data top-level tag.
> > > - add idMethod="native" to all tables (I've tried the deprecated
> "sequence"
> > > too, for grins)
> > >
> > > Running his test program, I get the error: cannot insert NULL into
> > > ("AQUI1"."AUTHOR"."AUTHOR_ID")
> > > (AUTHOR_ID is the autoincrement key)
> > >
> > > ----
> > > I've done what I can to scour the mailing list (I have
> village-1.5.3-dev.jar
> > > as per one posting).
> > > I tried playing around w/ the source and jdb... couldn't figure out
> much.  I
> > > don't have Village source; for one reason, because www.working-dogs.com
> is
> > > not responding tonight.
> > >
> > > I don't know where the sequence/insert is supposed to be composed
> anyway.
> > > I did follow
> > >
> http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04064.html
> > > and see that Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
> > > at line 767 of BasePeer.java is returning null...  but I can't figure
> out
> > > what to do with his advice:
> > >
> >
> >          #elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod ==
> > "native" && $dbprops.get("idMethod") == "sequence"))
> >         tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
> >
> > the line above ~98 from MapBuilder.vm should be inserting the sequence
> > name as the needed information.  Do you not see any code from this in
> > your generated map builder classes?  Note setSequenceInfo just calls
> > setPrimaryKeyMethodInfo.
> >
> >
> >
> >
> > > tMap.setSequenceInfo( insert HARD-CODED key information here );
> > > I put his fragment in MapBuilder.vm and the generated code in
> > > AuthorMapBuilder.java now looks like this:
> > >      tMap.setSequenceInfo( getAuthor_Id() );
> > >      tMap.addPrimaryKey ( getAuthor_Id(), new Integer(0) );
> > >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: standalone Torque and Oracle (NULL insert problem again)

Posted by Jim Mackraz <ji...@mackraz.com>.
My fault.  Need to read more on DatabaseServices adapater properties.

jdm

----- Original Message -----
From: "Jim Mackraz" <ji...@mackraz.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, November 04, 2001 12:30 PM
Subject: Re: standalone Torque and Oracle (NULL insert problem again)


> Problem is now: database adapter being setup is DBMM.
> Here's the jdb view of things...
> Jim
>
> main[1] where
>   [1] org.apache.torque.util.BasePeer.doInsert (BasePeer.java:766)
>   [2] com.trickybit.torque.test.BaseAuthorPeer.doInsert
> (BaseAuthorPeer.java:130)
>   [3] com.trickybit.torque.test.BaseAuthorPeer.doInsert
> (BaseAuthorPeer.java:375)
>   [4] com.trickybit.torque.test.BaseAuthor.save (BaseAuthor.java:500)
>   [5] com.trickybit.torque.test.BaseAuthor.save (BaseAuthor.java:470)
>   [6] com.trickybit.torque.test.BaseAuthor.save (BaseAuthor.java:453)
>   [7] com.trickybit.mytest.MyTest.main (MyTest.java:25)
> main[1] list
> 762                }
> 763
> 764                DatabaseMap dbMap = Torque.getDatabaseMap(
> criteria.getDbName() );
> 765                TableMap tableMap = dbMap.getTable(tableName);
> 766     =>         Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
> 767                IdGenerator keyGen = tableMap.getIdGenerator();
> 768
> 769                ColumnMap pk = getPrimaryKey(criteria);
> 770                // only get a new key value if you need to
> 771                // the reason is that a primary key might be defined
> main[1] next
> main[1]
> Step completed: thread="main", org.apache.torque.util.BasePeer.doInsert(),
> line=767, bci=72
>   767         IdGenerator keyGen = tableMap.getIdGenerator();
>
> main[1] print keyInfo
>  keyInfo = "AUTHOR_SEQ"
> main[1] next
> main[1]
> Step completed: thread="main", org.apache.torque.util.BasePeer.doInsert(),
> line=769, bci=79
>   769         ColumnMap pk = getPrimaryKey(criteria);
>
> main[1] dump keyGen
>  keyGen = instance of
org.apache.torque.oid.AutoIncrementIdGenerator(id=503)
> {
>     dbAdapter: instance of org.apache.torque.adapter.DBMM(id=504)
> }
>
> ----- Original Message -----
> From: "Jim Mackraz" <ji...@mackraz.com>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Sunday, November 04, 2001 11:57 AM
> Subject: Re: standalone Torque and Oracle (NULL insert problem again)
>
>
> > This fix indeed adds this line in AuthorMapBuilder.java:
> >         tMap.setPrimaryKeyMethodInfo("AUTHOR_SEQ");
> >
> > Unfortunately, I still get a NULL insert error.
> > I've double-checked that I'm building the right source, and I'll go back
> > into jdb in a little while and see what I can.
> >
> > ---- from other email:
> > >automatic pulling of
> > properties into the context as the property is named "database" and the
> > context key is "targetDatabase".
> >
> > Ah, thanks, I saw no call in the source to the setTargetDatabase, didn't
> > know about that particular magic.
> >
> >   Jim
> >
> > ----- Original Message -----
> > From: "John McNally" <jm...@collab.net>
> > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Sent: Sunday, November 04, 2001 11:18 AM
> > Subject: Re: standalone Torque and Oracle (NULL insert problem again)
> >
> >
> > > Add the following line to src/conf/build.xml.  I added this when it
> > > seemed it was going to be necessary to add some db specific processing
> > > to the om templates.  Previously the om templates had no db specific
> > > code in them as most of this is handled through adapter classes.
Jason
> > > then deleted the line, still thinking there was no reason the om
> > > templates needed to know the database.  I will add it back now.
> > >
> > > john mcnally
> > >
> > > Index: src//conf/build.xml
> > > ===================================================================
> > > RCS file: /home/cvs/jakarta-turbine-torque/src/conf/build.xml,v
> > > retrieving revision 1.11
> > > diff -u -r1.11 build.xml
> > > --- src//conf/build.xml 2001/11/01 02:23:01 1.11
> > > +++ src//conf/build.xml 2001/11/04 19:05:42
> > > @@ -330,6 +330,7 @@
> > >        outputFile="report.${project}.om.generation"
> > >        targetPackage="${targetPackage}.om"
> > >
xmlFile="${torque.home}/${schemaDirectory}/${project}-schema.xml"
> > > +      targetDatabase="${database}"
> > >      />
> > >
> > >    </target>
> > >
> > > Jim Mackraz wrote:
> > > >
> > > > A little followup:
> > > >
> > > > In the standalone source tree, I see no occurence of
> setTargetDatabase()
> > > > anywhere under: jakarta-turbine-torque/src
> > > >
> > > > That would appear to be necessary to set $targetDatabase in any of
the
> > > > sundry Torque*Task contexts..
> > > >
> > > > ----- Original Message -----
> > > > From: "John McNally" <jm...@collab.net>
> > > > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > > > Sent: Sunday, November 04, 2001 9:36 AM
> > > > Subject: Re: standalone Torque and Oracle (NULL insert problem
again)
> > > >
> > > > > Jim Mackraz wrote:
> > > > > >
> > > > > > I am using the recipe for standalone torque from Steve Davis
> (torque
> > > > outside
> > > > > > turbine - detailed example (long))
> > > > > >
> > > >
> >
http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg03639.html
> > > > > > [THANKS, Steve!]
> > > > > >
> > > > > > The recipe includes building torque from cvs
> jakarta-turbine-torque,
> > > > etc.
> > > > > > I checked out jakarta-turbine-torque tonight (2Nov2001) and did
> just
> > > > that.
> > > > > >
> > > > > > I'm using Steve's bookstore schema w/ two changes:
> > > > > > - remove app-data top-level tag.
> > > > > > - add idMethod="native" to all tables (I've tried the deprecated
> > > > "sequence"
> > > > > > too, for grins)
> > > > > >
> > > > > > Running his test program, I get the error: cannot insert NULL
into
> > > > > > ("AQUI1"."AUTHOR"."AUTHOR_ID")
> > > > > > (AUTHOR_ID is the autoincrement key)
> > > > > >
> > > > > > ----
> > > > > > I've done what I can to scour the mailing list (I have
> > > > village-1.5.3-dev.jar
> > > > > > as per one posting).
> > > > > > I tried playing around w/ the source and jdb... couldn't figure
> out
> > > > much.  I
> > > > > > don't have Village source; for one reason, because
> > www.working-dogs.com
> > > > is
> > > > > > not responding tonight.
> > > > > >
> > > > > > I don't know where the sequence/insert is supposed to be
composed
> > > > anyway.
> > > > > > I did follow
> > > > > >
> > > >
> >
>
http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04064.html
> > > > > > and see that Object keyInfo =
tableMap.getPrimaryKeyMethodInfo();
> > > > > > at line 767 of BasePeer.java is returning null...  but I can't
> > figure
> > > > out
> > > > > > what to do with his advice:
> > > > > >
> > > > >
> > > > >          #elseif ($table.IdMethod == "sequence" ||
($table.IdMethod
> > ==
> > > > > "native" && $dbprops.get("idMethod") == "sequence"))
> > > > >         tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
> > > > >
> > > > > the line above ~98 from MapBuilder.vm should be inserting the
> sequence
> > > > > name as the needed information.  Do you not see any code from this
> in
> > > > > your generated map builder classes?  Note setSequenceInfo just
calls
> > > > > setPrimaryKeyMethodInfo.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > > tMap.setSequenceInfo( insert HARD-CODED key information here );
> > > > > > I put his fragment in MapBuilder.vm and the generated code in
> > > > > > AuthorMapBuilder.java now looks like this:
> > > > > >      tMap.setSequenceInfo( getAuthor_Id() );
> > > > > >      tMap.addPrimaryKey ( getAuthor_Id(), new Integer(0) );
> > > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > >
> > > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: standalone Torque and Oracle (NULL insert problem again)

Posted by Jim Mackraz <ji...@mackraz.com>.
Problem is now: database adapter being setup is DBMM.
Here's the jdb view of things...
Jim

main[1] where
  [1] org.apache.torque.util.BasePeer.doInsert (BasePeer.java:766)
  [2] com.trickybit.torque.test.BaseAuthorPeer.doInsert
(BaseAuthorPeer.java:130)
  [3] com.trickybit.torque.test.BaseAuthorPeer.doInsert
(BaseAuthorPeer.java:375)
  [4] com.trickybit.torque.test.BaseAuthor.save (BaseAuthor.java:500)
  [5] com.trickybit.torque.test.BaseAuthor.save (BaseAuthor.java:470)
  [6] com.trickybit.torque.test.BaseAuthor.save (BaseAuthor.java:453)
  [7] com.trickybit.mytest.MyTest.main (MyTest.java:25)
main[1] list
762                }
763
764                DatabaseMap dbMap = Torque.getDatabaseMap(
criteria.getDbName() );
765                TableMap tableMap = dbMap.getTable(tableName);
766     =>         Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
767                IdGenerator keyGen = tableMap.getIdGenerator();
768
769                ColumnMap pk = getPrimaryKey(criteria);
770                // only get a new key value if you need to
771                // the reason is that a primary key might be defined
main[1] next
main[1]
Step completed: thread="main", org.apache.torque.util.BasePeer.doInsert(),
line=767, bci=72
  767         IdGenerator keyGen = tableMap.getIdGenerator();

main[1] print keyInfo
 keyInfo = "AUTHOR_SEQ"
main[1] next
main[1]
Step completed: thread="main", org.apache.torque.util.BasePeer.doInsert(),
line=769, bci=79
  769         ColumnMap pk = getPrimaryKey(criteria);

main[1] dump keyGen
 keyGen = instance of org.apache.torque.oid.AutoIncrementIdGenerator(id=503)
{
    dbAdapter: instance of org.apache.torque.adapter.DBMM(id=504)
}

----- Original Message -----
From: "Jim Mackraz" <ji...@mackraz.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, November 04, 2001 11:57 AM
Subject: Re: standalone Torque and Oracle (NULL insert problem again)


> This fix indeed adds this line in AuthorMapBuilder.java:
>         tMap.setPrimaryKeyMethodInfo("AUTHOR_SEQ");
>
> Unfortunately, I still get a NULL insert error.
> I've double-checked that I'm building the right source, and I'll go back
> into jdb in a little while and see what I can.
>
> ---- from other email:
> >automatic pulling of
> properties into the context as the property is named "database" and the
> context key is "targetDatabase".
>
> Ah, thanks, I saw no call in the source to the setTargetDatabase, didn't
> know about that particular magic.
>
>   Jim
>
> ----- Original Message -----
> From: "John McNally" <jm...@collab.net>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Sunday, November 04, 2001 11:18 AM
> Subject: Re: standalone Torque and Oracle (NULL insert problem again)
>
>
> > Add the following line to src/conf/build.xml.  I added this when it
> > seemed it was going to be necessary to add some db specific processing
> > to the om templates.  Previously the om templates had no db specific
> > code in them as most of this is handled through adapter classes.  Jason
> > then deleted the line, still thinking there was no reason the om
> > templates needed to know the database.  I will add it back now.
> >
> > john mcnally
> >
> > Index: src//conf/build.xml
> > ===================================================================
> > RCS file: /home/cvs/jakarta-turbine-torque/src/conf/build.xml,v
> > retrieving revision 1.11
> > diff -u -r1.11 build.xml
> > --- src//conf/build.xml 2001/11/01 02:23:01 1.11
> > +++ src//conf/build.xml 2001/11/04 19:05:42
> > @@ -330,6 +330,7 @@
> >        outputFile="report.${project}.om.generation"
> >        targetPackage="${targetPackage}.om"
> >        xmlFile="${torque.home}/${schemaDirectory}/${project}-schema.xml"
> > +      targetDatabase="${database}"
> >      />
> >
> >    </target>
> >
> > Jim Mackraz wrote:
> > >
> > > A little followup:
> > >
> > > In the standalone source tree, I see no occurence of
setTargetDatabase()
> > > anywhere under: jakarta-turbine-torque/src
> > >
> > > That would appear to be necessary to set $targetDatabase in any of the
> > > sundry Torque*Task contexts..
> > >
> > > ----- Original Message -----
> > > From: "John McNally" <jm...@collab.net>
> > > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > > Sent: Sunday, November 04, 2001 9:36 AM
> > > Subject: Re: standalone Torque and Oracle (NULL insert problem again)
> > >
> > > > Jim Mackraz wrote:
> > > > >
> > > > > I am using the recipe for standalone torque from Steve Davis
(torque
> > > outside
> > > > > turbine - detailed example (long))
> > > > >
> > >
> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg03639.html
> > > > > [THANKS, Steve!]
> > > > >
> > > > > The recipe includes building torque from cvs
jakarta-turbine-torque,
> > > etc.
> > > > > I checked out jakarta-turbine-torque tonight (2Nov2001) and did
just
> > > that.
> > > > >
> > > > > I'm using Steve's bookstore schema w/ two changes:
> > > > > - remove app-data top-level tag.
> > > > > - add idMethod="native" to all tables (I've tried the deprecated
> > > "sequence"
> > > > > too, for grins)
> > > > >
> > > > > Running his test program, I get the error: cannot insert NULL into
> > > > > ("AQUI1"."AUTHOR"."AUTHOR_ID")
> > > > > (AUTHOR_ID is the autoincrement key)
> > > > >
> > > > > ----
> > > > > I've done what I can to scour the mailing list (I have
> > > village-1.5.3-dev.jar
> > > > > as per one posting).
> > > > > I tried playing around w/ the source and jdb... couldn't figure
out
> > > much.  I
> > > > > don't have Village source; for one reason, because
> www.working-dogs.com
> > > is
> > > > > not responding tonight.
> > > > >
> > > > > I don't know where the sequence/insert is supposed to be composed
> > > anyway.
> > > > > I did follow
> > > > >
> > >
>
http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04064.html
> > > > > and see that Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
> > > > > at line 767 of BasePeer.java is returning null...  but I can't
> figure
> > > out
> > > > > what to do with his advice:
> > > > >
> > > >
> > > >          #elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod
> ==
> > > > "native" && $dbprops.get("idMethod") == "sequence"))
> > > >         tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
> > > >
> > > > the line above ~98 from MapBuilder.vm should be inserting the
sequence
> > > > name as the needed information.  Do you not see any code from this
in
> > > > your generated map builder classes?  Note setSequenceInfo just calls
> > > > setPrimaryKeyMethodInfo.
> > > >
> > > >
> > > >
> > > >
> > > > > tMap.setSequenceInfo( insert HARD-CODED key information here );
> > > > > I put his fragment in MapBuilder.vm and the generated code in
> > > > > AuthorMapBuilder.java now looks like this:
> > > > >      tMap.setSequenceInfo( getAuthor_Id() );
> > > > >      tMap.addPrimaryKey ( getAuthor_Id(), new Integer(0) );
> > > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > >
> > > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: standalone Torque and Oracle (NULL insert problem again)

Posted by Jim Mackraz <ji...@mackraz.com>.
This fix indeed adds this line in AuthorMapBuilder.java:
        tMap.setPrimaryKeyMethodInfo("AUTHOR_SEQ");

Unfortunately, I still get a NULL insert error.
I've double-checked that I'm building the right source, and I'll go back
into jdb in a little while and see what I can.

---- from other email:
>automatic pulling of
properties into the context as the property is named "database" and the
context key is "targetDatabase".

Ah, thanks, I saw no call in the source to the setTargetDatabase, didn't
know about that particular magic.

  Jim

----- Original Message -----
From: "John McNally" <jm...@collab.net>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, November 04, 2001 11:18 AM
Subject: Re: standalone Torque and Oracle (NULL insert problem again)


> Add the following line to src/conf/build.xml.  I added this when it
> seemed it was going to be necessary to add some db specific processing
> to the om templates.  Previously the om templates had no db specific
> code in them as most of this is handled through adapter classes.  Jason
> then deleted the line, still thinking there was no reason the om
> templates needed to know the database.  I will add it back now.
>
> john mcnally
>
> Index: src//conf/build.xml
> ===================================================================
> RCS file: /home/cvs/jakarta-turbine-torque/src/conf/build.xml,v
> retrieving revision 1.11
> diff -u -r1.11 build.xml
> --- src//conf/build.xml 2001/11/01 02:23:01 1.11
> +++ src//conf/build.xml 2001/11/04 19:05:42
> @@ -330,6 +330,7 @@
>        outputFile="report.${project}.om.generation"
>        targetPackage="${targetPackage}.om"
>        xmlFile="${torque.home}/${schemaDirectory}/${project}-schema.xml"
> +      targetDatabase="${database}"
>      />
>
>    </target>
>
> Jim Mackraz wrote:
> >
> > A little followup:
> >
> > In the standalone source tree, I see no occurence of setTargetDatabase()
> > anywhere under: jakarta-turbine-torque/src
> >
> > That would appear to be necessary to set $targetDatabase in any of the
> > sundry Torque*Task contexts..
> >
> > ----- Original Message -----
> > From: "John McNally" <jm...@collab.net>
> > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Sent: Sunday, November 04, 2001 9:36 AM
> > Subject: Re: standalone Torque and Oracle (NULL insert problem again)
> >
> > > Jim Mackraz wrote:
> > > >
> > > > I am using the recipe for standalone torque from Steve Davis (torque
> > outside
> > > > turbine - detailed example (long))
> > > >
> >
http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg03639.html
> > > > [THANKS, Steve!]
> > > >
> > > > The recipe includes building torque from cvs jakarta-turbine-torque,
> > etc.
> > > > I checked out jakarta-turbine-torque tonight (2Nov2001) and did just
> > that.
> > > >
> > > > I'm using Steve's bookstore schema w/ two changes:
> > > > - remove app-data top-level tag.
> > > > - add idMethod="native" to all tables (I've tried the deprecated
> > "sequence"
> > > > too, for grins)
> > > >
> > > > Running his test program, I get the error: cannot insert NULL into
> > > > ("AQUI1"."AUTHOR"."AUTHOR_ID")
> > > > (AUTHOR_ID is the autoincrement key)
> > > >
> > > > ----
> > > > I've done what I can to scour the mailing list (I have
> > village-1.5.3-dev.jar
> > > > as per one posting).
> > > > I tried playing around w/ the source and jdb... couldn't figure out
> > much.  I
> > > > don't have Village source; for one reason, because
www.working-dogs.com
> > is
> > > > not responding tonight.
> > > >
> > > > I don't know where the sequence/insert is supposed to be composed
> > anyway.
> > > > I did follow
> > > >
> >
http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04064.html
> > > > and see that Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
> > > > at line 767 of BasePeer.java is returning null...  but I can't
figure
> > out
> > > > what to do with his advice:
> > > >
> > >
> > >          #elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod
==
> > > "native" && $dbprops.get("idMethod") == "sequence"))
> > >         tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
> > >
> > > the line above ~98 from MapBuilder.vm should be inserting the sequence
> > > name as the needed information.  Do you not see any code from this in
> > > your generated map builder classes?  Note setSequenceInfo just calls
> > > setPrimaryKeyMethodInfo.
> > >
> > >
> > >
> > >
> > > > tMap.setSequenceInfo( insert HARD-CODED key information here );
> > > > I put his fragment in MapBuilder.vm and the generated code in
> > > > AuthorMapBuilder.java now looks like this:
> > > >      tMap.setSequenceInfo( getAuthor_Id() );
> > > >      tMap.addPrimaryKey ( getAuthor_Id(), new Integer(0) );
> > > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: standalone Torque and Oracle (NULL insert problem again)

Posted by John McNally <jm...@collab.net>.
Add the following line to src/conf/build.xml.  I added this when it
seemed it was going to be necessary to add some db specific processing
to the om templates.  Previously the om templates had no db specific
code in them as most of this is handled through adapter classes.  Jason
then deleted the line, still thinking there was no reason the om
templates needed to know the database.  I will add it back now.

john mcnally

Index: src//conf/build.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/conf/build.xml,v
retrieving revision 1.11
diff -u -r1.11 build.xml
--- src//conf/build.xml	2001/11/01 02:23:01	1.11
+++ src//conf/build.xml	2001/11/04 19:05:42
@@ -330,6 +330,7 @@
       outputFile="report.${project}.om.generation"
       targetPackage="${targetPackage}.om"
       xmlFile="${torque.home}/${schemaDirectory}/${project}-schema.xml"
+      targetDatabase="${database}"
     />
 
   </target>

Jim Mackraz wrote:
> 
> A little followup:
> 
> In the standalone source tree, I see no occurence of setTargetDatabase()
> anywhere under: jakarta-turbine-torque/src
> 
> That would appear to be necessary to set $targetDatabase in any of the
> sundry Torque*Task contexts..
> 
> ----- Original Message -----
> From: "John McNally" <jm...@collab.net>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Sunday, November 04, 2001 9:36 AM
> Subject: Re: standalone Torque and Oracle (NULL insert problem again)
> 
> > Jim Mackraz wrote:
> > >
> > > I am using the recipe for standalone torque from Steve Davis (torque
> outside
> > > turbine - detailed example (long))
> > >
> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg03639.html
> > > [THANKS, Steve!]
> > >
> > > The recipe includes building torque from cvs jakarta-turbine-torque,
> etc.
> > > I checked out jakarta-turbine-torque tonight (2Nov2001) and did just
> that.
> > >
> > > I'm using Steve's bookstore schema w/ two changes:
> > > - remove app-data top-level tag.
> > > - add idMethod="native" to all tables (I've tried the deprecated
> "sequence"
> > > too, for grins)
> > >
> > > Running his test program, I get the error: cannot insert NULL into
> > > ("AQUI1"."AUTHOR"."AUTHOR_ID")
> > > (AUTHOR_ID is the autoincrement key)
> > >
> > > ----
> > > I've done what I can to scour the mailing list (I have
> village-1.5.3-dev.jar
> > > as per one posting).
> > > I tried playing around w/ the source and jdb... couldn't figure out
> much.  I
> > > don't have Village source; for one reason, because www.working-dogs.com
> is
> > > not responding tonight.
> > >
> > > I don't know where the sequence/insert is supposed to be composed
> anyway.
> > > I did follow
> > >
> http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04064.html
> > > and see that Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
> > > at line 767 of BasePeer.java is returning null...  but I can't figure
> out
> > > what to do with his advice:
> > >
> >
> >          #elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod ==
> > "native" && $dbprops.get("idMethod") == "sequence"))
> >         tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
> >
> > the line above ~98 from MapBuilder.vm should be inserting the sequence
> > name as the needed information.  Do you not see any code from this in
> > your generated map builder classes?  Note setSequenceInfo just calls
> > setPrimaryKeyMethodInfo.
> >
> >
> >
> >
> > > tMap.setSequenceInfo( insert HARD-CODED key information here );
> > > I put his fragment in MapBuilder.vm and the generated code in
> > > AuthorMapBuilder.java now looks like this:
> > >      tMap.setSequenceInfo( getAuthor_Id() );
> > >      tMap.addPrimaryKey ( getAuthor_Id(), new Integer(0) );
> > >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: standalone Torque and Oracle (NULL insert problem again)

Posted by Jason van Zyl <jv...@zenplex.com>.
On 11/4/01 2:05 PM, "Jim Mackraz" <ji...@mackraz.com> wrote:

> A little followup:
> 
> In the standalone source tree, I see no occurence of setTargetDatabase()
> anywhere under: jakarta-turbine-torque/src
> 
> That would appear to be necessary to set $targetDatabase in any of the
> sundry Torque*Task contexts..

The value is set in a  properties file and is pulled into, and made
available in the context via the contextProperties attribute to the base
texen task that is the parent of most of the torque tasks.

I think we will move to making all required properties explicit. The use of
contextProperties allows you to add things to the context without having to
change the task code but it's a bit loosy goosy and has caused some
collision problems.
 
> ----- Original Message -----
> From: "John McNally" <jm...@collab.net>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Sunday, November 04, 2001 9:36 AM
> Subject: Re: standalone Torque and Oracle (NULL insert problem again)
> 
> 
>> Jim Mackraz wrote:
>>> 
>>> I am using the recipe for standalone torque from Steve Davis (torque
> outside
>>> turbine - detailed example (long))
>>> 
> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg03639.html
>>> [THANKS, Steve!]
>>> 
>>> The recipe includes building torque from cvs jakarta-turbine-torque,
> etc.
>>> I checked out jakarta-turbine-torque tonight (2Nov2001) and did just
> that.
>>> 
>>> I'm using Steve's bookstore schema w/ two changes:
>>> - remove app-data top-level tag.
>>> - add idMethod="native" to all tables (I've tried the deprecated
> "sequence"
>>> too, for grins)
>>> 
>>> Running his test program, I get the error: cannot insert NULL into
>>> ("AQUI1"."AUTHOR"."AUTHOR_ID")
>>> (AUTHOR_ID is the autoincrement key)
>>> 
>>> ----
>>> I've done what I can to scour the mailing list (I have
> village-1.5.3-dev.jar
>>> as per one posting).
>>> I tried playing around w/ the source and jdb... couldn't figure out
> much.  I
>>> don't have Village source; for one reason, because www.working-dogs.com
> is
>>> not responding tonight.
>>> 
>>> I don't know where the sequence/insert is supposed to be composed
> anyway.
>>> I did follow
>>> 
> http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04064.html
>>> and see that Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
>>> at line 767 of BasePeer.java is returning null...  but I can't figure
> out
>>> what to do with his advice:
>>> 
>> 
>>          #elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod ==
>> "native" && $dbprops.get("idMethod") == "sequence"))
>>         tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
>> 
>> the line above ~98 from MapBuilder.vm should be inserting the sequence
>> name as the needed information.  Do you not see any code from this in
>> your generated map builder classes?  Note setSequenceInfo just calls
>> setPrimaryKeyMethodInfo.
>> 
>> 
>> 
>> 
>>> tMap.setSequenceInfo( insert HARD-CODED key information here );
>>> I put his fragment in MapBuilder.vm and the generated code in
>>> AuthorMapBuilder.java now looks like this:
>>>      tMap.setSequenceInfo( getAuthor_Id() );
>>>      tMap.addPrimaryKey ( getAuthor_Id(), new Integer(0) );
>>> 
>> 
>> --
>> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>> 
>> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: standalone Torque and Oracle (NULL insert problem again)

Posted by Jim Mackraz <ji...@mackraz.com>.
A little followup:

In the standalone source tree, I see no occurence of setTargetDatabase()
anywhere under: jakarta-turbine-torque/src

That would appear to be necessary to set $targetDatabase in any of the
sundry Torque*Task contexts..

----- Original Message -----
From: "John McNally" <jm...@collab.net>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, November 04, 2001 9:36 AM
Subject: Re: standalone Torque and Oracle (NULL insert problem again)


> Jim Mackraz wrote:
> >
> > I am using the recipe for standalone torque from Steve Davis (torque
outside
> > turbine - detailed example (long))
> >
http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg03639.html
> > [THANKS, Steve!]
> >
> > The recipe includes building torque from cvs jakarta-turbine-torque,
etc.
> > I checked out jakarta-turbine-torque tonight (2Nov2001) and did just
that.
> >
> > I'm using Steve's bookstore schema w/ two changes:
> > - remove app-data top-level tag.
> > - add idMethod="native" to all tables (I've tried the deprecated
"sequence"
> > too, for grins)
> >
> > Running his test program, I get the error: cannot insert NULL into
> > ("AQUI1"."AUTHOR"."AUTHOR_ID")
> > (AUTHOR_ID is the autoincrement key)
> >
> > ----
> > I've done what I can to scour the mailing list (I have
village-1.5.3-dev.jar
> > as per one posting).
> > I tried playing around w/ the source and jdb... couldn't figure out
much.  I
> > don't have Village source; for one reason, because www.working-dogs.com
is
> > not responding tonight.
> >
> > I don't know where the sequence/insert is supposed to be composed
anyway.
> > I did follow
> >
http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04064.html
> > and see that Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
> > at line 767 of BasePeer.java is returning null...  but I can't figure
out
> > what to do with his advice:
> >
>
>          #elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod ==
> "native" && $dbprops.get("idMethod") == "sequence"))
>         tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
>
> the line above ~98 from MapBuilder.vm should be inserting the sequence
> name as the needed information.  Do you not see any code from this in
> your generated map builder classes?  Note setSequenceInfo just calls
> setPrimaryKeyMethodInfo.
>
>
>
>
> > tMap.setSequenceInfo( insert HARD-CODED key information here );
> > I put his fragment in MapBuilder.vm and the generated code in
> > AuthorMapBuilder.java now looks like this:
> >      tMap.setSequenceInfo( getAuthor_Id() );
> >      tMap.addPrimaryKey ( getAuthor_Id(), new Integer(0) );
> >
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: standalone Torque and Oracle (NULL insert problem again)

Posted by Jim Mackraz <ji...@mackraz.com>.
Thanks, Jon, here's a little drill-down that eventually reaches the nut, but
it's still unexplained...

In MapBuilder.vm I see:
        #if ($table.IdMethod == "idbroker")
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        #elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod ==
"native" && $dbprops.get("idMethod") == "sequence"))
        tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
        #elseif ($table.IdMethodParameters)
        // this might need upgrading based on what all the databases
        // need, but for now assume one parameter.
        #set ($imp = $table.IdMethodParameters.get(0) )
        tMap.setPrimaryKeyMethodInfo("$imp.Value");
        #end


But in my generated *MapBuilder.java I only see:
        dbMap.addTable(getTable());
        TableMap tMap = dbMap.getTable(getTable());

                tMap.setPrimaryKeyMethod(TableMap.NATIVE);

So it would appear that I'm missing some component of that conditional...
In oracle/db.props I see:
idMethod=sequence

In my schema defn I see:
 <table name="BOOK" idMethod="native">

--------
So in MapBuilder.vm I put:
        // Table ID Method: $table.IdMethod
        // DBProps ID Method: $dbprops.get("idMethod")

and in the .java  I got:

        // Table ID Method: native
        // DBProps ID Method: $dbprops.get("idMethod")

So... $dbprops isn't making it through..  I see no other occurence of
$dbprops in this .vm

I see dbprops is set up in Control.vm (which I don't know anything about).
So I tried again:
        // Tale ID Method: $table.IdMethod
        // DBProps ID Method: $dbprops.get("idMethod")
        // propfile:
$generator.TemplatePath/sql/base/$targetDatabase/db.props
        // target database: $targetDatabase
yields:

        // Tale ID Method: native
        // DBProps ID Method: $dbprops.get("idMethod")
        // propfile:
/home/jim/j/TorqueTest/torque/templates/sql/base/$targetDatabase/db.props
        // target database: $targetDatabase

So... It's $targetDatabase that's missing...

In build properties, I have:
database = oracle

So, if there's some other place I need to specify targetDatabase, I'm
probably missing it.
I presume it doesn't need to be placed in the <database> tag of the
schema...

 Thanks again for your help, I hope my experiments here shed some light.
I'll keep poking around from here (grep targetDatabase) but I'll get this
off to you.

[Do you want this kind of stuff through the maillist, or direct email?]
 Jim

>
>          #elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod ==
> "native" && $dbprops.get("idMethod") == "sequence"))
>         tMap.setPrimaryKeyMethodInfo("$table.SequenceName");
>
> the line above ~98 from MapBuilder.vm should be inserting the sequence
> name as the needed information.  Do you not see any code from this in
> your generated map builder classes?  Note setSequenceInfo just calls
> setPrimaryKeyMethodInfo.
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: standalone Torque and Oracle (NULL insert problem again)

Posted by John McNally <jm...@collab.net>.
Jim Mackraz wrote:
> 
> I am using the recipe for standalone torque from Steve Davis (torque outside
> turbine - detailed example (long))
> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg03639.html
> [THANKS, Steve!]
> 
> The recipe includes building torque from cvs jakarta-turbine-torque, etc.
> I checked out jakarta-turbine-torque tonight (2Nov2001) and did just that.
> 
> I'm using Steve's bookstore schema w/ two changes:
> - remove app-data top-level tag.
> - add idMethod="native" to all tables (I've tried the deprecated "sequence"
> too, for grins)
> 
> Running his test program, I get the error: cannot insert NULL into
> ("AQUI1"."AUTHOR"."AUTHOR_ID")
> (AUTHOR_ID is the autoincrement key)
> 
> ----
> I've done what I can to scour the mailing list (I have village-1.5.3-dev.jar
> as per one posting).
> I tried playing around w/ the source and jdb... couldn't figure out much.  I
> don't have Village source; for one reason, because www.working-dogs.com is
> not responding tonight.
> 
> I don't know where the sequence/insert is supposed to be composed anyway.
> I did follow
> http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg04064.html
> and see that Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
> at line 767 of BasePeer.java is returning null...  but I can't figure out
> what to do with his advice:
>

         #elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod ==
"native" && $dbprops.get("idMethod") == "sequence"))
        tMap.setPrimaryKeyMethodInfo("$table.SequenceName");

the line above ~98 from MapBuilder.vm should be inserting the sequence
name as the needed information.  Do you not see any code from this in
your generated map builder classes?  Note setSequenceInfo just calls
setPrimaryKeyMethodInfo.




> tMap.setSequenceInfo( insert HARD-CODED key information here );
> I put his fragment in MapBuilder.vm and the generated code in
> AuthorMapBuilder.java now looks like this:
>      tMap.setSequenceInfo( getAuthor_Id() );
>      tMap.addPrimaryKey ( getAuthor_Id(), new Integer(0) );
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>