Hibernate version: 3.2.2.ga
Mapping documents:/b]
Annotations: Class in question has this method signature
Code:
/**
* @return the status
*/
@Enumerated
@Column(name = "status", nullable = false, updatable = false)
public Status getStatus() {
return status;
}
[b]Code between sessionFactory.openSession() and session.close():Handled by Spring
Full stack trace of any exception that occurs:Code:
[junit] Error typecasting value <ACTIVE> to INTEGER
[junit] org.dbunit.dataset.datatype.TypeCastException: Error typecasting value <ACTIVE> to INTEGER
[junit] at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:63)
[junit] at org.dbunit.dataset.datatype.IntegerDataType.setSqlValue(IntegerDataType.java:81)
[junit] at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:62)
[junit] at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:52)
[junit] at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:174)
[junit] at com.my.app.testutils.DatabaseTestDAO.onSetUpBeforeTransaction(DatabaseTestDAO.java:79)
[junit] at com.my.app.dao.hibernate.ForumDAOTest.onSetUpBeforeTransaction(ForumDAOTest.java:27)
[junit] at org.springframework.test.AbstractTransactionalSpringContextTests.onSetUp(AbstractTransactionalSpringContextTests.java:167)
[junit] at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:85)
[junit] at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001(AbstractAnnotationAwareTransactionalTests.java:44)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run(AbstractAnnotationAwareTransactionalTests.java:112)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest(AbstractAnnotationAwareTransactionalTests.java:177)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed(AbstractAnnotationAwareTransactionalTests.java:150)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare(AbstractAnnotationAwareTransactionalTests.java:108)
[junit] java.lang.NumberFormatException
[junit] at java.math.BigDecimal.<init>(BigDecimal.java:368)
[junit] at java.math.BigDecimal.<init>(BigDecimal.java:647)
[junit] at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:59)
[junit] at org.dbunit.dataset.datatype.IntegerDataType.setSqlValue(IntegerDataType.java:81)
[junit] at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:62)
[junit] at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:52)
[junit] at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:174)
[junit] at com.my.app.testutils.DatabaseTestDAO.onSetUpBeforeTransaction(DatabaseTestDAO.java:79)
[junit] at com.my.app.dao.hibernate.ForumDAOTest.onSetUpBeforeTransaction(ForumDAOTest.java:27)
[junit] at org.springframework.test.AbstractTransactionalSpringContextTests.onSetUp(AbstractTransactionalSpringContextTests.java:167)
[junit] at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:85)
[junit] at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001(AbstractAnnotationAwareTransactionalTests.java:44)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run(AbstractAnnotationAwareTransactionalTests.java:112)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest(AbstractAnnotationAwareTransactionalTests.java:177)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed(AbstractAnnotationAwareTransactionalTests.java:150)
[junit] at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare(AbstractAnnotationAwareTransactionalTests.java:108)
Name and version of the database you are using:The generated SQL (show_sql=true):NA
Debug level Hibernate log excerpt:NA
Here is the part of the criteria query I'm having problems with
DetachedCriteria criteria = DetachedCriteria.forClass(getPersistedClass());
criteria.add(Restrictions.eq("status", Status.ACTIVE));
...
If I use @Enumerated(EnumType.STRING) I have no issues but I would like to use the ordinal value. How would I do that using the criteria API?[/code]