For standalone hibernate its easy to do, when you create the persistence object you can pass it a hash-table of key-value pairs. In your case the key "hibernate.hbm2dll.auto" and value of "validate"...
private Map properties = Util.newMap();
public EntityManagerFactory getEntityManagerFactory() {
if (emf == null || !emf.isOpen()) {
emf = Persistence.createEntityManagerFactory(PU, properties);
}
return emf;
}
public EntityManager getEntityManager() {
if (em == null || !em.isOpen()) {
em = getEntityManagerFactory().createEntityManager();
}
return em;
}
I then would have my configuration class populate the Map with things from my custom configuration file.
I don't believe you can modify an already open EntityManager instance. And though you can pass the EntityManager a Map, I found that it ignored those properties and only paid attention when you did it from the Factory...