java - How to get Hibernate Tools to generate POJOs with toString,equals and hashcode? -
hibernate tools plugin (version 3.2.4) eclipse
hi all,
i'm using plugin reverse engineer pojos , daos db-schema , reason tostring,equals , hashcode methods aren't created in pojos.
i'm doing following: create new jpa project.
configure it's persistence.xml file follows:
<persistence-unit name="pu"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="hibernate.connection.driver_class" value="com.microsoft.sqlserver.jdbc.sqlserverdriver"/> <property name="hibernate.connection.password" value="pass"/> <property name="hibernate.connection.url" value="jdbc:sqlserver://****:1433;databasename=mydb"/> <property name="hibernate.connection.username" value="user"/> <property name="hibernate.default_catalog" value="mydb"/> <property name="hibernate.dialect" value="org.hibernate.dialect.sqlserverdialect"/> <property name="hibernate.connection.schema" value="dbo"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="false"/>
created hibernate.reveng.xml file select dbo scehma in catalog.
created hibernate console configuration type jpa , connection taken jpa config, , lastly configured persistence unit.
used hibernate code generation configurations create new config enabled "reverse engineer jdbc connection" defined output directory, package , reveng file.
in addition checked checkboxes in tab (apart use custom templates).
in exporters tab used:
1. use java 5 syntax.
2. generate ejb3 annotations.
, used "domain code" , "dao code" exporters.
works fine (after solving problems dtp plugin compatibality).
main problem see in pojo.ftl following expressions:
<#include "pojotostring.ftl"/> <#include "pojoequalshashcode.ftl"/>
and in pojotostring.ftl see:
<#if pojo.needstostring()>
where can set property? want pojos need tostring,equals , hashcode?
thank in advance
this assumes default hibernate tools/jboss tools
you define each column want have tostring() or equals() call. provide meta property
<table schema="public" name="somename" class="com.stackovervlow"> <primary-key> </primary-key> <column name="xx" property="id" type="long"> <meta attribute="use-in-tostring">true</meta> <meta attribute="scope-set">private</meta> </column> <column name="yy"> <meta attribute="use-in-tostring">true</meta> <meta attribute="use-in-equals">true</meta> </column> </table>
Comments
Post a Comment