Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I also have difficulties understanding the question, but I'll try to rephrase:</p> <ul> <li>You have a lot of data in a DB and want to access it via JPA</li> <li>You don't want to manually write the classes to access the different DBs/tables</li> <li>Currently all/most of your model classes are generated from within Eclipse</li> <li>These models have JPA annotations</li> <li>The model classes (or the annotations) are not according to corporate standards</li> </ul> <p>When you say "JPA java code generation", I understand generating JPA annotated model classes from a supplied DB connection. Most frameworks often refer to this as reverse engineering.</p> <p>Now you have two questions:</p> <ol> <li>What code generators can be recommended to generate JPA annotated classes?</li> <li>Is it possible to customize the output of these frameworks, and in which way?</li> </ol> <p>To answer to the first question:</p> <ul> <li><a href="http://tools.hibernate.org" rel="noreferrer">Hibernate Tools</a> - already mentioned in the question, but I prefer this one</li> <li><a href="http://www.eclipse.org/eclipselink/" rel="noreferrer">EclipseLink</a></li> <li><a href="http://wiki.netbeans.org/BestPracticesWithJPAAndBeansBinding" rel="noreferrer">Netbeans</a></li> </ul> <p>I really like the Netbeans code generation, especially if you show the results to someone not familiar with JPA.</p> <p>At the level of customization I can only share the experience I had with Hibernate Tools. Especially for reproducible results, try to use the <a href="http://docs.jboss.org/tools/3.0.0.CR1/en/hibernatetools/html_single/index.html#ant" rel="noreferrer">ant-based tasks</a>. You can easily add some targets to your build and code generation can be done at two levels:</p> <ul> <li>Configure exporters using <a href="http://docs.jboss.org/tools/3.0.0.CR1/en/hibernatetools/html_single/index.html#d0e3669" rel="noreferrer">properties</a></li> <li>Provide custom <a href="http://freemarker.sourceforge.net/" rel="noreferrer">freemarker templates</a></li> </ul> <p>With the templates you should be able to cover most of the corporate standards. Look into the <code>pojo</code> directory of the hibernate-tools package. The easiest way to customize the code generation is to copy and adapt the templates and have them put before the hibernate-tools.jar in the ant task used to create the pojos.</p> <p>As already pointed out in another comment, it might be difficult to modify the generated code afterwards. I hope the following tips can help you:</p> <ul> <li>Try to separate generated and customized source files in different folders.</li> <li>Think about using <code><a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/MappedSuperclass.html" rel="noreferrer">@MappedSuperclass</a></code> for classes which you may want to adapt in a manual step.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload