List of usage examples for org.hibernate.internal SessionImpl getJdbcConnectionAccess
JdbcConnectionAccess getJdbcConnectionAccess();
From source file:org.jadira.usertype.dateandtime.joda.TestPersistentDateTime.java
License:Apache License
@Test @Ignore// ww w. j a v a 2 s . c o m public void testRead() throws SQLException { SessionImpl session = (SessionImpl) (factory.createEntityManager().getDelegate()); Connection conn = session.getJdbcConnectionAccess().obtainConnection(); String insertTableSQL = "INSERT INTO dateTime" + "(ID, NAME, DATETIME) VALUES" + "(?,?,?)"; for (int i = 0; i < dateTimes.length; i++) { PreparedStatement preparedStatement = conn.prepareStatement(insertTableSQL); preparedStatement.setInt(1, i); preparedStatement.setString(2, "test_" + i); preparedStatement.setTimestamp(3, dateTimes[i] == null ? null : new java.sql.Timestamp(dateTimes[i].getMillis())); preparedStatement.executeUpdate(); } conn.commit(); for (int i = 0; i < dateTimes.length; i++) { JodaDateTimeHolder item = find(JodaDateTimeHolder.class, i); assertNotNull(item); assertEquals(i, item.getId()); assertEquals("test_" + i, item.getName()); if (dateTimes[i] == null) { assertNull(item.getDateTime()); } else { assertEquals(dateTimes[i].withZone(DateTimeZone.UTC).toString(), item.getDateTime().toString()); } } verifyDatabaseTable(); }