Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* @author Vlad Mihalcea
Expand All @@ -26,21 +27,24 @@ protected String[] getMappings() {
@Test
@TestForIssue(jiraKey = "HHH-10766")
public void hbmEnumWithExplicitTypeTest() {
Session s = openSession();
s.getTransaction().begin();
Person painted = Person.person( Gender.MALE, HairColor.BROWN );
painted.setOriginalHairColor( HairColor.BLONDE );
s.persist( painted );
s.getTransaction().commit();
s.clear();
Session s = openSession();
try {
s.getTransaction().begin();
Person painted = Person.person(Gender.MALE, HairColor.BROWN);
painted.setOriginalHairColor(HairColor.BLONDE);
s.persist(painted);
s.getTransaction().commit();
s.clear();

s.getTransaction().begin();
Number id = (Number) session.createSQLQuery(
"select id from Person where originalHairColor = :color" )
.setParameter( "color", HairColor.BLONDE.name() )
.uniqueResult();
assertEquals( 1L, id.longValue() );
s.getTransaction().commit();
s.close();
s.getTransaction().begin();
Object id = session.createSQLQuery(
"select id from Person where originalHairColor = :color")
.setParameter("color", HairColor.BLONDE.name())
.uniqueResult();
assertTrue(id instanceof Number);
} finally {
s.getTransaction().commit();
s.close();
}
}
}