Skip to content

Instantly share code, notes, and snippets.

@johnament
Created March 18, 2013 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnament/5189053 to your computer and use it in GitHub Desktop.
Save johnament/5189053 to your computer and use it in GitHub Desktop.
ShrinkWrap can be ugly
public static void updatePersistence(final PersistenceDescriptor pd) {
for (final PersistenceUnit<PersistenceDescriptor> pu : pd.getAllPersistenceUnit()) {
Property<Properties<PersistenceUnit<PersistenceDescriptor>>> hbm2ddl = null;
for (final Property<Properties<PersistenceUnit<PersistenceDescriptor>>> prop : pu.getOrCreateProperties()
.getAllProperty()) {
if (prop.getName().equals("hibernate.hbm2ddl.auto")) {
hbm2ddl = prop;
break;
}
}
if (hbm2ddl == null) {
hbm2ddl = pu.getOrCreateProperties().createProperty();
hbm2ddl.name("hibernate.hbm2ddl.auto");
}
hbm2ddl.value("create-drop");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment