-
1. Re: How to get db column comments with Hibernate reverse engineering?
maxandersen May 28, 2013 11:01 AM (in response to surkov)you'll need to add $table.comment to the templates of hbm2java.
-
2. Re: How to get db column comments with Hibernate reverse engineering?
surkov Jun 3, 2013 11:19 AM (in response to maxandersen)Could you tell my where templates of hbm2java are situated? I have to edit them ? or I have to write them ? May be you have an example of $table.comment adding...
-
3. Re: How to get db column comments with Hibernate reverse engineering?
maxandersen Jun 4, 2013 3:17 AM (in response to surkov)They are inside the hibernatetools-*.jar.
Unzip that jar.
copy the hbm2java directory into your own directory, i.e. "templates" so you have templates/hbm2java/*.ftl
Now use "templates" as your template path in hibernate code generation.
It will now look in this directory before looking in the jar.
Meaning you can add things into these *.ftl files and they should show up in your generated entities.
-
4. Re: How to get db column comments with Hibernate reverse engineering?
surkov Jun 4, 2013 10:32 AM (in response to maxandersen)Thanks it's worked!!! By it is another problem...It lost code page...I have Oracle UTF8 database and i use russian letters in comments. How can a resolve it ?
Here is generated comments (((....
/**
* ���������� �05.������� ������������
*/
private RefAccreditationDomain refAccreditationDomain;
my Hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">a</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@192.168.11.237:1521:devorcl</property>
<property name="hibernate.connection.username">ACRED</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.characterEncoding">UTF-8</property>
<property name="hibernate.connection.charSet">UTF-8</property>
</session-factory>
</hibernate-configuration>
and my PojoFields.ftl
<#foreach field in pojo.getAllPropertiesIterator()>
<#if pojo.getMetaAttribAsBool(field, "gen-property", true)>
<#foreach column in field.columnIterator>
<#if column.comment?exists && column.comment?trim?length!=0>
/**
* ${column.comment}
*/
</#if>
</#foreach>
${pojo.getFieldModifiers(field)} ${pojo.getJavaTypeName(field, jdk5)} ${field.name}
<#if pojo.hasFieldInitializor(field, jdk5)>
= ${pojo.getFieldInitialization(field, jdk5)}
</#if>;
</#if>
</#foreach>
-
5. Re: How to get db column comments with Hibernate reverse engineering?
maxandersen Jun 4, 2013 6:02 PM (in response to surkov)1 of 1 people found this helpfulcan you try and ensure your java-vm runs with default character encoding set to UTF-8 ?
Try adding -Dfile.encoding=UTF-8 on command line arguments for eclipse.
I believe hibernate tools uses the default encoding which might explain this.
-
6. Re: How to get db column comments with Hibernate reverse engineering?
surkov Jun 5, 2013 12:14 PM (in response to maxandersen)Thanks it' worked))) a've added
-Dfile.encoding=UTF-8 to my eclipce.ini file...))) .. And i have another one question. How can I change type Set to ArrayList<AnyType> in my in my generated files? Is there any simple way to do this?