Apart from that latter consideration there is no need to invoke on an already persisted entity because any changes will automatically be saved at flush or commit time.



From the identifier generators to associations, there are many options to choose from, yet not all choices are equal from a performance perspective.For synthetic keys, the application developer can either choose a randomly generates fixed-size sequence (e.g. Natural identifiers are very practical, being more compact than their UUID counterparts, so there are multiple generators to choose from: generator addresses the portability concern, in reality, it performs poorly because it requires emulating a database sequence using a separate transaction and row-level locks.For this reason, the choice is usually between generator, then you should be using the enhanced identifier generators that were enabled by default in Hibernate 5.So, if at this point you haven't read the first tutorial on JPA 2, you might want to do it now.As always a few assumptions are made, like basic knowledge of SQL and relational databases, what an EJB is and where does it run, Unit Testing, an IDE is setup (like Net Beans) , a My SQL database is setup and basic knowledge on how to use it and , as stated before : All the things that were explained on the first JPA Tutorial: Getting Started with JPA 2 Tutorial Also, the source code used for the demonstration later on this tutorial can be found here : .