Below code uses JPA and Spring and can create a row in the table "games".
@Repository
@Transactional
public class GameDao {
/**
* Save the game in the database.
*/
public void create(Game game) {
entityManager.persist(game);
return;
}
// An EntityManager will be automatically injected from entityManagerFactory
// setup on DatabaseConfig class.
@PersistenceContext
private EntityManager entityManager;
}
Looking at this create function, I wonder how does it find the table that it is supposed to insert?
If it can just find out the table from the argument type (Game game), can I create a class called CreateDao and do all the create operations from there?