// to entityManager.merge that plugin POJO, it would null out that blob column.
if (plugin.getId() == 0) {
entityManager.persist(plugin);
} else {
// update all the fields except content
Plugin pluginEntity = entityManager.getReference(Plugin.class, plugin.getId());
pluginEntity.setName(plugin.getName());
pluginEntity.setPath(plugin.getPath());
pluginEntity.setDisplayName(plugin.getDisplayName());
pluginEntity.setEnabled(plugin.isEnabled());
pluginEntity.setStatus(plugin.getStatus());
pluginEntity.setMd5(plugin.getMD5());
pluginEntity.setVersion(plugin.getVersion());
pluginEntity.setAmpsVersion(plugin.getAmpsVersion());
pluginEntity.setDeployment(plugin.getDeployment());
pluginEntity.setDescription(plugin.getDescription());
pluginEntity.setHelp(plugin.getHelp());
pluginEntity.setMtime(plugin.getMtime());
try {
entityManager.flush(); // make sure we push this out to the DB now
} catch (Exception e) {
throw new Exception("Failed to update a plugin that matches [" + plugin + "]");