-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 27 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: HBM2X NEED HELP
PostPosted: Fri Sep 30, 2005 3:53 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
Hibernate version:
extracted from JBossIDE-N200509280156-ALL.zip

First, Max i apologize it was a mistake for precedent topic. I downloaded 0925 build

Second, when i run hbm2x task as follow

<target name="generate.java">
<hibernatetool>
<classpath>
<path location="${java.directory}"/>
</classpath>
<jdbcconfiguration configurationfile="./hibernate-cfg.xml"
revengfile="hibernate-reveng.xml"
packagename="fr.ccip.test"/>

<cfg2hbm destdir="${hbm.directory}"/>
<hbm2x destdir="${java.directory}" template="${template.directory}/domain/interface.vm" filepattern="{package}/{class}.java"/>

</hibernatetool>
</target>


I get a {package} folder with a {class}.java file inside


[template]

$c2j.getPackageDeclaration($clazz)
import java.util.*;

$c2j.addExtraImports($clazz,$ctx)
$secondpassclassimports

/**
$c2j.getClassJavaDoc($clazz, $render.eval($ctx, "$c2j.getDeclarationName($clazz) generated by CCIP custom template"),0)
*/


public interface $c2j.getDeclarationName($clazz) {

## Property accessors for interface
#foreach($property in $c2j.getAllPropertiesIterator($clazz))
/**
$c2j.toJavaDoc($c2j.getMetaAsString($property, "field-description"),4) */
$c2j.getPropertyGetModifiers($property) $c2j.stripPackage( $c2j.getJavaTypeName($property), $clazz ) $c2j.getGetterSignature($property)();

$c2j.getPropertySetModifiers($property) void set$c2j.getPropertyName($property)($c2j.stripPackage( $c2j.getJavaTypeName($property), $clazz ) $property.Name);
#end

}



[results]

$c2j.getPackageDeclaration($clazz)
import java.util.*;

$c2j.addExtraImports($clazz,$ctx)
$secondpassclassimports

/**
$c2j.getClassJavaDoc($clazz, $render.eval($ctx, "$c2j.getDeclarationName($clazz) generated by CCIP custom template"),0)
*/

public interface $c2j.getDeclarationName($clazz) {

}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 4:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so you downloaded 25-9 build ? I dont think the {package}/{class} support was there at that time.

Furthermore you are using the "old" style of writing a template.

$c2j is still there, but not as prominent as it used to be.
Look at the new Pojo.vm and friends to see how to get information.

I need to update the docs about it, but until then you would need to look around in the examples/junittests ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 4:51 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
thx max for info (new vm design)
I've got a 28-9 1:56 build
I'didn't saw a recently build but perhaps I'm mad ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 5:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
some of the nightly builds have been timing out so some nights might be missing at the moment

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: new vm
PostPosted: Fri Sep 30, 2005 9:03 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
Max,
with build 28-05
Do you think the build is not complete or I'm very stupid and missed something ?



[Ant task]

<hbm2x destdir="${java.directory}" template="${template.directory}domain/pojo.vm" filepattern="Addressbook.java"/>

[vm file]
$pojo.getPackageDeclaration()
$secondpassclassimports

public interface $pojo.getDeclarationName() {

#foreach($property in $pojo.getAllPropertiesIterator())
/**
$c2j.toJavaDoc($c2j.getMetaAsString($property, "field-description"),4) */
$pojo.getPropertyGetModifiers($property) $pojo.importType( $c2j.getJavaTypeName($property) ) $pojo.getGetterSignature($property)();

$pojo.getPropertySetModifiers($property) void set$pojo.getPropertyName($property)($pojo.importType( $c2j.getJavaTypeName($property) ) $property.Name);
#end

}


[output]

$pojo.getPackageDeclaration()
$secondpassclassimports

public interface $pojo.getDeclarationName() {


}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm it should work ;)

is the filename correct ?

you could try and iterate ctx.internalGetKeys() and see what objects that are actually in the context.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:21 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
I don't know how to manage the filename
The hbm is Addressbook.hbm and the class is Addressbook
so i set pattern to Addressbook.java

[ant output]
$pojo.getPackageDeclaration() is not a valid reference.
$secondpassclassimports is not a valid reference.
$pojo.getDeclarationName() is not a valid reference.
Writing ./template/domain/pojo.vm to D:\dev\projects\Hbm2java-test\java\Addressbook.java


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:25 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
when i put ctx.internalGetKeys() in the pojo.vm, i've got it in the java output file ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
try to do itearate $ctx.internalGetKeys() and tell me what it returns.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:31 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
no sorry i forgot $... i'm newbie in velocity sorry for basic errors
i'll watch


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
btw. i think i've found the cause of the filepattern problems.

its {package-name} and {class-name} you should use.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:36 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
exporter
render
cfg
templates
ctx
c2j
c2h
artifacts


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:42 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
Ok that work with the new file pattern, you're a boss

[keys]
exporter
render
pojo
clazz
cfg
templates
ctx
c2j
c2h
artifacts


just an error on $secondpassclassimports :
$secondpassclassimports is not a valid reference

You save my week-end ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
<hbm2x> doesnt do anything special for imports - i guess it just as well could.

add it to jira

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 9:59 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
ahahahahha it's too much powerful
you're a big boss velocity hibernate man, max ;-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 27 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.