dleal wrote:
max wrote:
well that is because you are putting "true" in the last argument which is the default value if none is found ;)
Also note that another cause can be that you have put the meta element in the top of the file and all properties have inherited it - you avoid that with inherit="false"
On the original file you will see a similar use of getMetaAttribAsBool, at that place it uses the third argument too:
Code:
<#if pojo.getMetaAttribAsBool(property, "gen-property", true)>
<#if pojo.hasFieldJavaDoc(property)>
/**
* ${pojo.getFieldJavaDoc(property, 4)}
*/
</#if>
What I am duing is the same, if I don't put the true I get an Exception.
yes, because then it will return null and thus be undefined.
if not all elements has the meta attribute and no reasonable default is possible (you could maybe use an empty string?) then you should use the c2j.hasMetaAttribute(property, "blahblah") method (the ones on pojo is just shortcuts to this one.)
Then you can check if the property has the value or not.
Quote:
Your suggestion look good and with sense, but it doesn't work, probably because if you put a new meta attribute you have to tell hibernate it is a new meta attribute. As you can see I am using the same sintax as for property "gen-property", but hibernate expect such meta attribute.
yes - its still simple and it works just as described.
Quote:
It is a common problem (adding pre/post conditions), but it doesn't look so simple to really get the desire output. Have you tried such suggestion about meta attribute really?
The templates are full of dependencies on metaattribute working so yes i have tried it.
Quote:
Where I can find the definition of the method invoked on the *.ftl files. I know it is Freemarker, but there are defined some method specifically for hibernate. For example like the method:
Code:
<#if pojo.hasMetaAttribute("class-code")> // The following is extra code specified in the hbm.xml files
${pojo.getExtraClassCode()}
// end of extra code specified in the hbm.xml files
</#if>
where is such getExtraClassCode defined?
On POJOClass.
Quote:
On my opinions, it should be easier to define a method like getPreConditionMethodCode(), getPostConditionMethodCode(), that to get finally work modifying the template, :-)
see
http://www.hibernate.org/hib_docs/tools ... e/#d0e1179 for how to expose your own java logic.
Quote:
Any why there is no so much documetation about how to add additional conditions to the generated methods, I would like it works but it doesn't.
no one haven't sat down and written it yet. Want to contribute it ?
Your case would actually be a good way to demonstrate how to extend the templates.