Discussion:
[jboss-user] [JBoss Tools] - Re: How to get db column comments with Hibernate reverse engineering?
Max Rydahl Andersen
2013-05-28 15:02:05 UTC
Permalink
Max Rydahl Andersen [https://community.jboss.org/people/maxandersen] created the discussion

"Re: How to get db column comments with Hibernate reverse engineering?"

To view the discussion, visit: https://community.jboss.org/message/819915#819915

--------------------------------------------------------------
you'll need to add $table.comment to the templates of hbm2java.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/819915#819915]

Start a new discussion in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128]
vova surkov
2013-06-03 15:19:10 UTC
Permalink
vova surkov [https://community.jboss.org/people/surkov] created the discussion

"Re: How to get db column comments with Hibernate reverse engineering?"

To view the discussion, visit: https://community.jboss.org/message/821038#821038

--------------------------------------------------------------
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...
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/821038#821038]

Start a new discussion in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128]
Max Rydahl Andersen
2013-06-04 07:17:39 UTC
Permalink
Max Rydahl Andersen [https://community.jboss.org/people/maxandersen] created the discussion

"Re: How to get db column comments with Hibernate reverse engineering?"

To view the discussion, visit: https://community.jboss.org/message/821166#821166

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/821166#821166]

Start a new discussion in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128]
vova surkov
2013-06-04 14:32:59 UTC
Permalink
vova surkov [https://community.jboss.org/people/surkov] created the discussion

"Re: How to get db column comments with Hibernate reverse engineering?"

To view the discussion, visit: https://community.jboss.org/message/821307#821307

--------------------------------------------------------------
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 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>
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/821307#821307]

Start a new discussion in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128]
Max Rydahl Andersen
2013-06-04 22:02:27 UTC
Permalink
Max Rydahl Andersen [https://community.jboss.org/people/maxandersen] created the discussion

"Re: How to get db column comments with Hibernate reverse engineering?"

To view the discussion, visit: https://community.jboss.org/message/821394#821394

--------------------------------------------------------------
can 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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/821394#821394]

Start a new discussion in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128]
vova surkov
2013-06-05 16:14:13 UTC
Permalink
vova surkov [https://community.jboss.org/people/surkov] created the discussion

"Re: How to get db column comments with Hibernate reverse engineering?"

To view the discussion, visit: https://community.jboss.org/message/821558#821558

--------------------------------------------------------------
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?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/821558#821558]

Start a new discussion in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128]
Loading...