Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Configuration configuration = new Configuration().configure();
SessionFactory factory = configuration.buildSessionFactory();
Session session = factory.getCurrentSession();
Transaction transaction = session.getTransaction();
//insert one user
String sql = "INSERT INTO users (id, name, created_at_utc)"
+ "VALUES (1, 'Adam Spring', '2016-06-12 14:54:15')";
Query query = session.createSQLQuery(sql);
//read one user
User user = (User) session.createCriteria(User.class).list().get(0);
System.out.print("Time in ms: " + user.getCreatedAtUtc().getTime()); //date represented in miliseconds since epoch unix time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.