As a yet "newbie" of JavaEE, say I try to implement a rather big RESTful API with Spring 4 and Hibernate and, the final JSON objects should be transformed to flattened Objects other than the original Java bean entities annotated with @Entity
.
Due to the "out-of-the-box" feature of Spring and Hibernate, I am sure most programmers can easily get the work done. But as an experienced programmer, we would focus more on the code structure, design architecture so that the whole project is more maintainable and code is easy to read.
So my first question is the package
structure:
where to place the Java bean entities annotated with
@Entity
? I have seen some people place them in the package calledmodel
, I am not exactly clear about their purpose anywayWhere to place the final flattened objects transformed from the Java bean entities? I placed it in the package called
dto
as this is data transfer object between theservice
layer and thecontroller
layer
so I have the following package structure:
sample.model //place the @Entity Java beans
sample.dto //place the aforementioned DTO
sample.controller //place the controller class
Anyone can give some comments on it? Thanks in advance
There's two different ways to organize packages in Java project.
Comparison
But how to name your package it's really up to you.
In different projects, I faced with names like: