Skip to content

Instantly share code, notes, and snippets.

@blakeman8192
Created February 28, 2013 20:41
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 blakeman8192/de57273f472ceaf1b7d8 to your computer and use it in GitHub Desktop.
Save blakeman8192/de57273f472ceaf1b7d8 to your computer and use it in GitHub Desktop.
public static <M extends Model> M get(Class<M> type, Serializable id) {
Session session = newSession();
Transaction t = session.beginTransaction();
Object model = null;
try {
model = session.get(type, id);
t.commit();
} catch (HibernateException ex) {
t.rollback();
throw ex;
}
return (M) model;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment