Skip to content

Instantly share code, notes, and snippets.

@goodspb
Last active August 21, 2022 05:55
Show Gist options
  • Save goodspb/68a895e1be472621af71e75813169147 to your computer and use it in GitHub Desktop.
Save goodspb/68a895e1be472621af71e75813169147 to your computer and use it in GitHub Desktop.
medium JPA
@Transactional
@Override
public <S extends T> S save(S entity) {
Assert.notNull(entity, "Entity must not be null.");
if (entityInformation.isNew(entity)) {
em.persist(entity);
return entity;
} else {
return em.merge(entity);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment