How to generate domain objects using annotations using hibernation tools

I use the Hibernate tools for Eclipse to create domain classes starting from my database, and you need to add JPA annotations.

Is there any way to add annotations? Perhaps with reveng.xml and Reverse Engineering? How to do it?

Generated Domain Code:

public class Country implements java.io.Serializable { private long id; private String description; private String identifier; private String futureuse; private Set accounts = new HashSet(0); public Country() { } public Country(long id, String description, String identifier) { this.id = id; this.description = description; this.identifier = identifier; } ... 

Required Code:

 @Entity @Table(name = "COUNTRY") public class Country implements java.io.Serializable { @Id @Column(name="CNTR_ID") private Long id; @Column(name="CNTR_FUTUREUSE") private String futureUse; @Column(name="CNTR_IDENTIFIER") private String identifier; @Column(name="CNTR_DESCRIPTION") private String description; private Set accounts = new HashSet(0); public Country() { } public Country(long id, String description, String identifier) { this.id = id; this.description = description; this.identifier = identifier; } ... 
+4
source share
1 answer

I personally do not use sleep mode tools because I am very pleased with Spring Roo. However, a google search led me to this.

Generally there is a good tutorial from mkyong.com. If you go to "Hibernate" and click "Code Generation Configuration" on the "Export" tab, the "Generate EJB3 Annotations" checkbox will appear.

http://www.mkyong.com/hibernate/how-to-generate-code-with-hibernate-tools/

This has been confirmed in previous answers.

Can a Hibernate tool generate JPA POJO?

+12
source

Source: https://habr.com/ru/post/1493633/


All Articles