-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Java 5 Enum with Criteria API
PostPosted: Wed Apr 11, 2007 1:08 am 
Newbie

Joined: Tue Apr 04, 2006 10:58 pm
Posts: 6
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]


Top
 Profile  
 
 Post subject: Anyone
PostPosted: Wed Apr 11, 2007 5:14 pm 
Newbie

Joined: Tue Apr 04, 2006 10:58 pm
Posts: 6
So does the criteria API not support java 5 enum using the default ordinal association?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.