You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Christine Keim <im...@ycn.com> on 2002/07/04 00:11:20 UTC

Need Torque to create only classes with attributes and getter/setter methods from the project-schema

hi there,

i'm using TDK 2.1 and the added Torque version.
I am in need of Torque to let me generate classes from the project-schema.xml,
which only hold the the attributes i stated in the xml and absolutely do NOT
generate any save-Methods and Peers as well as no table.

This is because i have a SuperClass which holds all relevant items, and the 
subclasses i want to generate are only holders for attributes which don't go
in the relational DB (they go in a XML-DB actually).

I tried to achieve my goal in different ways.

a) i tried to define an alias for a table since i thought this doesn't generate
the table. I was right for the table, but look at the field test i wanted to
be generated as a property of the class Product as well as their getter/setter-Methods.
It didn't generate it at all.

  <table name="Product" javaName="Product" alias="KnowledgeObject"
  baseClass="iknow.share.om.KnowledgeObject">
    <!-- Unique identifier -->
    <column name="id" primaryKey="true" required="true" type="integer"/>
    <!-- Fields for XML -->
    <column name="test" size="255" type="VARCHAR"/>
  </table>

b) second try, i looked into the database.dtd. There i found skipSql. Now i really
don't know what this does(i didn't find a doku of it), but it sounded really like 
something i maybe wanted. So i tried the following, which caused the table not 
to be created (good!) but at the generation of the OM-Classes ant stopped
with a generator.parse exception (it is thrown only when i use skipSql=true):

  <table name="Product" javaName="Product" skipSql="true"
  baseClass="iknow.share.om.KnowledgeObject">
    <!-- Unique identifier -->
    <column name="id" primaryKey="true" required="true" type="integer"/>
    <!-- Fields for XML -->
    <column name="test" size="255" type="VARCHAR"/>
  </table>

Now, i was wondering if someone could tell me if skipSql is the key to the solution
or there is something far more easy to accomplish what i want.

If skipSql is the right choice, maybe someone knows why the following exception is thrown?
Please help me! ^^

Christine

BUILD FAILED

/usr/local/share/tdk/webapps/km01/WEB-INF/build/build.xml:178: Exception thrown by 'generator.parse'. For more information consult the velocity log.
at org.apache.velocity.texen.ant.TexenTask.execute(TexenTask.java)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:104)
at org.apache.tools.ant.Task.perform(Task.java:217)
at org.apache.tools.ant.Target.execute(Target.java:184)
at org.apache.tools.ant.Target.performTasks(Target.java:202)
at org.apache.tools.ant.Project.executeTarget(Project.java:601)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:266)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:120)
at org.apache.tools.ant.Task.perform(Task.java:217)
at org.apache.tools.ant.Target.execute(Target.java:184)
at org.apache.tools.ant.Target.performTasks(Target.java:202)
at org.apache.tools.ant.Project.executeTarget(Project.java:601)
at org.apache.tools.ant.Project.executeTargets(Project.java:560)
at org.apache.tools.ant.Main.runBuild(Main.java:454)
at org.apache.tools.ant.Main.start(Main.java:153)
at org.apache.tools.ant.Main.main(Main.java:176)
--- Nested Exception ---
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getJavaNative' in  class org.apache.turbine.torque.engine.database.model.Column threw exception class java.lang.NullPointerException
at org.apache.velocity.runtime.parser.node.PropertyExecutor.execute(PropertyExecutor.java)
at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java)
at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
at org.apache.velocity.Template.merge(Template.java)
at org.apache.velocity.texen.Generator.parse(Generator.java)
at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java)
at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java)
at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
at org.apache.velocity.Template.merge(Template.java)
at org.apache.velocity.texen.Generator.parse(Generator.java)
at org.apache.velocity.texen.ant.TexenTask.execute(TexenTask.java)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:104)
at org.apache.tools.ant.Task.perform(Task.java:217)
at org.apache.tools.ant.Target.execute(Target.java:184)
at org.apache.tools.ant.Target.performTasks(Target.java:202)
at org.apache.tools.ant.Project.executeTarget(Project.java:601)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:266)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:120)
at org.apache.tools.ant.Task.perform(Task.java:217)
at org.apache.tools.ant.Target.execute(Target.java:184)
at org.apache.tools.ant.Target.performTasks(Target.java:202)
at org.apache.tools.ant.Project.executeTarget(Project.java:601)
at org.apache.tools.ant.Project.executeTargets(Project.java:560)
at org.apache.tools.ant.Main.runBuild(Main.java:454)
at org.apache.tools.ant.Main.start(Main.java:153)
at org.apache.tools.ant.Main.main(Main.java:176)

 


Re: Need Torque to create only classes with attributes and getter/setter methods from the project-schema

Posted by Dave <re...@leader-bg.com>.
Christine,

To mention I am new to TDK, so please do not rely very heavily on my answer, 
you should check it yourself.

>From what I read, skipSql=false should not generate the corresponding create 
table script in project-schema.sql (the actual name will depend on the 
project name you have for your app). I do not know why your are getting the 
exception when you have that as true.

My idea how to get just the properties + get/set methods is the following. As 
far I know, there is no torque flag to skip the rest of the java code. The om 
java code is generated based on the torque templates that you can find in 
tdk/webapps/your-app/WEB-INF/build/bin/torque/templates/om. If you open the 
corresponding .vm file, it will be very obvious how that works. I would think 
since all you need is to remove stuff, that should be very easy. Delete 
whatever you do not need from the torque templates and rerun the build again.

If you check the .../templates/ subdirectories, you will also find the 
templates that generate your sql code, etc.

Let me know if that works.

Regards,
Dave

On Wednesday 03 July 2002 18:11, Christine Keim wrote:
> hi there,
>
> i'm using TDK 2.1 and the added Torque version.
> I am in need of Torque to let me generate classes from the
> project-schema.xml, which only hold the the attributes i stated in the xml
> and absolutely do NOT generate any save-Methods and Peers as well as no
> table.
>
> This is because i have a SuperClass which holds all relevant items, and the
> subclasses i want to generate are only holders for attributes which don't
> go in the relational DB (they go in a XML-DB actually).
>
> I tried to achieve my goal in different ways.
>
> a) i tried to define an alias for a table since i thought this doesn't
> generate the table. I was right for the table, but look at the field test i
> wanted to be generated as a property of the class Product as well as their
> getter/setter-Methods. It didn't generate it at all.
>
>   <table name="Product" javaName="Product" alias="KnowledgeObject"
>   baseClass="iknow.share.om.KnowledgeObject">
>     <!-- Unique identifier -->
>     <column name="id" primaryKey="true" required="true" type="integer"/>
>     <!-- Fields for XML -->
>     <column name="test" size="255" type="VARCHAR"/>
>   </table>
>
> b) second try, i looked into the database.dtd. There i found skipSql. Now i
> really don't know what this does(i didn't find a doku of it), but it
> sounded really like something i maybe wanted. So i tried the following,
> which caused the table not to be created (good!) but at the generation of
> the OM-Classes ant stopped with a generator.parse exception (it is thrown
> only when i use skipSql=true):
>
>   <table name="Product" javaName="Product" skipSql="true"
>   baseClass="iknow.share.om.KnowledgeObject">
>     <!-- Unique identifier -->
>     <column name="id" primaryKey="true" required="true" type="integer"/>
>     <!-- Fields for XML -->
>     <column name="test" size="255" type="VARCHAR"/>
>   </table>
>
> Now, i was wondering if someone could tell me if skipSql is the key to the
> solution or there is something far more easy to accomplish what i want.
>
> If skipSql is the right choice, maybe someone knows why the following
> exception is thrown? Please help me! ^^
>
> Christine
>
> BUILD FAILED
>
> /usr/local/share/tdk/webapps/km01/WEB-INF/build/build.xml:178: Exception
> thrown by 'generator.parse'. For more information consult the velocity log.
> at org.apache.velocity.texen.ant.TexenTask.execute(TexenTask.java) at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:104) at
> org.apache.tools.ant.Task.perform(Task.java:217)
> at org.apache.tools.ant.Target.execute(Target.java:184)
> at org.apache.tools.ant.Target.performTasks(Target.java:202)
> at org.apache.tools.ant.Project.executeTarget(Project.java:601)
> at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:266)
> at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:120)
> at org.apache.tools.ant.Task.perform(Task.java:217)
> at org.apache.tools.ant.Target.execute(Target.java:184)
> at org.apache.tools.ant.Target.performTasks(Target.java:202)
> at org.apache.tools.ant.Project.executeTarget(Project.java:601)
> at org.apache.tools.ant.Project.executeTargets(Project.java:560)
> at org.apache.tools.ant.Main.runBuild(Main.java:454)
> at org.apache.tools.ant.Main.start(Main.java:153)
> at org.apache.tools.ant.Main.main(Main.java:176)
> --- Nested Exception ---
> org.apache.velocity.exception.MethodInvocationException: Invocation of
> method 'getJavaNative' in  class
> org.apache.turbine.torque.engine.database.model.Column threw exception
> class java.lang.NullPointerException at
> org.apache.velocity.runtime.parser.node.PropertyExecutor.execute(PropertyEx
>ecutor.java) at
> org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier
>.java) at
> org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.j
>ava) at
> org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.ja
>va) at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java) at
> org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatemen
>t.java) at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java) at
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
> at
> org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatemen
>t.java) at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java) at
> org.apache.velocity.runtime.directive.Foreach.render(Foreach.java) at
> org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.ja
>va) at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java) at
> org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatemen
>t.java) at
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
> at org.apache.velocity.Template.merge(Template.java)
> at org.apache.velocity.texen.Generator.parse(Generator.java)
> at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
>l.java:25) at java.lang.reflect.Method.invoke(Method.java:324)
> at
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java)
> at
> org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.j
>ava) at
> org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.ja
>va) at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java) at
> org.apache.velocity.runtime.directive.Foreach.render(Foreach.java) at
> org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.ja
>va) at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java) at
> org.apache.velocity.runtime.directive.Foreach.render(Foreach.java) at
> org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.ja
>va) at
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
> at org.apache.velocity.Template.merge(Template.java)
> at org.apache.velocity.texen.Generator.parse(Generator.java)
> at org.apache.velocity.texen.ant.TexenTask.execute(TexenTask.java)
> at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:104)
> at org.apache.tools.ant.Task.perform(Task.java:217)
> at org.apache.tools.ant.Target.execute(Target.java:184)
> at org.apache.tools.ant.Target.performTasks(Target.java:202)
> at org.apache.tools.ant.Project.executeTarget(Project.java:601)
> at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:266)
> at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:120)
> at org.apache.tools.ant.Task.perform(Task.java:217)
> at org.apache.tools.ant.Target.execute(Target.java:184)
> at org.apache.tools.ant.Target.performTasks(Target.java:202)
> at org.apache.tools.ant.Project.executeTarget(Project.java:601)
> at org.apache.tools.ant.Project.executeTargets(Project.java:560)
> at org.apache.tools.ant.Main.runBuild(Main.java:454)
> at org.apache.tools.ant.Main.start(Main.java:153)
> at org.apache.tools.ant.Main.main(Main.java:176)



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