reverse engineering - Hibernate - moving annotations from property (method) level to field level -
How do I generate a hibernate domain class from tables with annotations at the field level? I used the tool project and generated domain class to hibernate from the table in the database Generated sections have comments on recipient methods instead of field level. Please advise a way to generate domain classes, whose areas are annotated. Is there any refactoring facility available in Eclipse / IDEA etc. to move the annotation from the eclipse level to the field level?
Appreciate your help and time.
These steps are:
-
allocate "hibernate -tools.jar "For example, by doing a search within your eclipse folder, you will find it at
Celsius: \ eclipse \ plugins \ org.hibernate.eclipse_3. 4.1.xxx \ lib \ tools
-
Remove the temporary folder (the WinRar can do) For example,
[your project] \ Templates Remove
-
under [your project] \ template \ POJO folder, "Ejb3FieldGetAnnotation.ftl" create a file named
this file is actually a copy of "Ejb3PropertyGetAnnotation.ftl" but the word "property is changed from" all "field", because this file ringing all areas (properties that will be placed in a loop Repeat through the wheel). I include the contents of the file in this post
-
Remove property-level annotation: file "PojoPropertyAccessors.ftl", remove or comment out
< Code> & lt; # Include "GetPropertyAnnation.ftl" />
-
Add field-level comments: In the file "PojoFields.ftl",
add> lt; #include "Ejb3FieldGetAnnation. FTL" /> $ {Pojo.getFieldModifiers (field)} ...
-
When arise Java entities, select "Use custom templates" and Templates folder specified Please. In this situation, this [your project] will be templed
==================================== ================================================== ======= ===== Ejb3FieldGetAnnotationkftl =================================== =============================================== & lt; #if ejb3 & gt; & Lt; #if pojo.hasIdentifierProperty () & gt; & Lt; #if field.equals (clazz.identifierProperty) & gt; $ {Pojo.generateAnnIdGenerator ()} & lt; # - If this ID is the property (recipient) - & gt; & Lt; # - Clearly set the column name for this property - & gt; & Lt; / # If & gt; & Lt; / # If & gt; & Lt; #if c2h.isOneToOne (region) & gt; $ {Pojo.generateOneToOneAnnotation (Region, CFG)} & lt; #elseif c2h.isManyToOne (field) & gt; $ {Pojo.generateManyToOneAnnotation (area)} & lt; # - TODO support optional and target - - & gt; $ {Pojo.generateJoinColumnsAnnotation (field, cfg)} & lt; #elseif c2h.isCollection (field) & gt; $ {Pojo.generateCollectionAnnotation (field, cfg)} & lt; # Else & gt; $ {Pojo.generateBasicAnnotation (area)} $ {pojo.generateAnnColumnAnnotation (field)} & lt; / # If & gt; & Lt; / # If & gt;
Hope this will work for you.
Comments
Post a Comment