Automatically update / copy / inherit DTO javadocs from entity class

In our system, we get the managed entity ORM beans from the database (using sleep mode), and then we copy them to DTO beans for sending to the user interface.

Most properties in the DTO have the same name as the entities, but return types are often different because any objects associated with them must be converted to store only the identifier or another DTO.

In my world of perfect sleep, somehow, when I edited javadocs for an entity, javadocs on the same methods in the DTO would update to fit. This can be done using the build tool or the eclipse plugin.

Has anyone seen anything like this?

+3
source share
2 answers

Well, it is definitely possible. What you need is a source code parser, I would recommend javaparser .

Write two Visitors , one for reading JavaDocs and one for writing them. In both cases, you probably start with VoidVisitorAdapterand redefine public void visit(MethodDeclaration n, A arg)andpublic void visit(JavadocComment n, A arg)

Make it all available from the main class and call this main class via maven ( Exec-Maven-Plugin ) or ant ( Java Task ) at build time.

+1
source

I think that what you want may be unfounded.

DTO should not be displayed for the object. If still, why do you need a DTO?

, . , ORM. .

, DTO , . , , , , ..

. 4 DTO -. - .

, Java EE , DTO . , .

-1

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


All Articles