HHH-8401 : Unit test fixes

This commit is contained in:
Gail Badner 2014-12-17 23:21:51 -08:00
parent 275f3337f2
commit 45511f10ae
6 changed files with 14 additions and 58 deletions

View File

@ -37,7 +37,7 @@ public class Department implements java.io.Serializable {
private String deptName;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GeneratedValue
@Column(name="id_dep")
public Integer getDeptNo() {
return this.deptNo;

View File

@ -41,7 +41,7 @@ import javax.persistence.Table;
public class Employee implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GeneratedValue
@Column(name="id_emp")
private Integer id;

View File

@ -37,7 +37,7 @@ import javax.persistence.Table;
public class Title implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GeneratedValue
@Column(name="id_title")
private Integer id;

View File

@ -69,6 +69,13 @@ public class TimePropertyTest extends BaseCoreFunctionalTestCase {
s.getTransaction().commit();
s.close();
s = openSession();
s.getTransaction().begin();
final Query queryWithParameter = s.createQuery( "from TimePropertyTest$Entity where tAsDate=?" ).setParameter( 0, eOrig.tAsDate );
final Entity eQueriedWithParameter = (Entity) queryWithParameter.uniqueResult();
assertNotNull( eQueriedWithParameter );
s.getTransaction().commit();
s.close();
s = openSession();
s.getTransaction().begin();

View File

@ -151,55 +151,6 @@ public class TimestampPropertyTest extends BaseCoreFunctionalTestCase {
s.close();
}
@Test
public void testTimeGeneratedByColumnDefinition() {
final Entity eOrig = new Entity();
Session s = openSession();
s.getTransaction().begin();
s.persist( eOrig );
s.getTransaction().commit();
s.close();
assertNotNull( eOrig.tsColumnDefinition );
s = openSession();
s.getTransaction().begin();
final Entity eGotten = (Entity) s.get( Entity.class, eOrig.id );
final String tsColumnDefinitionOrigFormatted = timestampFormat.format( eOrig.tsColumnDefinition );
final String tsColumnDefinitionGottenFormatted = timestampFormat.format( eGotten.tsColumnDefinition );
assertEquals( tsColumnDefinitionOrigFormatted , tsColumnDefinitionGottenFormatted );
s.getTransaction().commit();
s.close();
s = openSession();
s.getTransaction().begin();
final Query queryWithParameter =
s.createQuery( "from TimestampPropertyTest$Entity where tsColumnDefinition=?" )
.setParameter( 0, eOrig.tsColumnDefinition );
final Entity eQueriedWithParameter = (Entity) queryWithParameter.uniqueResult();
assertNotNull( eQueriedWithParameter );
s.getTransaction().commit();
s.close();
s = openSession();
s.getTransaction().begin();
final Query queryWithTimestamp =
s.createQuery( "from TimestampPropertyTest$Entity where tsColumnDefinition=?" )
.setTimestamp( 0, eOrig.tsColumnDefinition );
final Entity eQueriedWithTimestamp = (Entity) queryWithTimestamp.uniqueResult();
assertNotNull( eQueriedWithTimestamp );
s.getTransaction().commit();
s.close();
s = openSession();
s.getTransaction().begin();
s.delete( eQueriedWithTimestamp );
s.getTransaction().commit();
s.close();
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] { Entity.class };
@ -218,10 +169,5 @@ public class TimestampPropertyTest extends BaseCoreFunctionalTestCase {
@Generated( value = GenerationTime.INSERT )
@ColumnDefault( value = "CURRENT_TIMESTAMP" )
private Date tsColumnDefault;
@Temporal( value = TemporalType.TIMESTAMP )
@Generated( value = GenerationTime.INSERT )
@Column( columnDefinition = "datetime(6) default NOW(6)" )
private Date tsColumnDefinition;
}
}

View File

@ -34,6 +34,7 @@ import java.util.Map;
import java.util.Set;
import org.hibernate.Session;
import org.hibernate.dialect.MySQL57InnoDBDialect;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.envers.configuration.EnversSettings;
@ -490,8 +491,10 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
Assert.assertNull( revEnd );
}
else {
if ( getDialect() instanceof MySQL5Dialect ) {
if ( getDialect() instanceof MySQL5Dialect && !( getDialect() instanceof MySQL57InnoDBDialect) ) {
// MySQL5 DATETIME column type does not contain milliseconds.
// MySQL 5.7 supports milliseconds and when MySQL57InnoDBDialect is used, it is assumed that
// the column is defined as DATETIME(6).
Assert.assertEquals(
revendTimestamp.getTime(),
(revEnd.getTimestamp() - (revEnd.getTimestamp() % 1000))