How to use Reflection to Document your Data Model based on JPA Annotations

About Brian Porter

So using JPA, Hiber­nate or EBeans is cool when you can just anno­tate your Java classes, but haven’t you always wished you could “gen­er­ate” doc­u­men­ta­tion of your data model from the code? Pulling infor­ma­tion of the the JPA / Hiber­nate  and other val­i­da­tion annotations?

Assum­ing you have all those nice Anno­ta­tions in your beans:
 
 
 
 
 

@Entity@Table(name = "project_bills")public class Bill extends Model {	private static final long serialVersionUID = 1L;	@Id	@Column(name="PBI_ID")	public Long id;	@DoubleFormat	@Column(name="PBI_BILL_AMOUNT",length=22)	public Double billAmount;	@Column(name="PBI_BILL_DATE")	@DateTime(pattern="dd.MM.yyyy")	public Date billDate;	@Column(name="PBI_BILL_NUMBER",length=10)	public String billNumber;	@Column(name="PBI_CAN_BILL")	public Boolean canBill;	@Column(name="PBI_COMMENT",length=65535)	public String comment;	@Column(name="PBI_PAID_DATE")	@DateTime(pattern="dd.MM.yyyy")	public Date paidDate;

Source : http://www.javacodegeeks.com/2013/07/how-to-use-reflection-to-document-your-data-model-based-on-jpa-annotations.html

Back to Top