On my current project it is a common practice to generate Hibernate Entities from database tables using NetBeans functionality. I'm normally used to first write the Entity-class and define the mapping in an XML-file or with annotations.

Is it considered bad practice to generate the entity classes through NetBeans (or another IDE) and are there any drawbacks to this approach?

We're only using Hibernate 4.3 and no JPA.

  • 2
    Without any context, it's impossible to offer an opinion. If a project is best served by generating Hibernate Entities from database tables using NetBeans functionality, then by definition it is the "best practice." Commented Jan 18, 2018 at 19:56

1 Answer 1


I don't see this as a problem, depending on your context.

In some cases you start with a database definition, perhaps you have the database from a previous project and have to adapt to it. So the database is set and your job is to provide a mapping to it. In this kind of situation you must do as you suggest.

In other cases you build something from scratch. Here it is in my opinion more a case of where the developer feels at home. Is he/she better at expressing the model through Hibernate entities or through a database definition. Then let the developer do as he/she pleases and let the other part be generated from that first artefact.

So, it may very well be a good practice in some cases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.