-->
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.  [ 1 post ] 
Author Message
 Post subject: Unknown name value for enum class ...
PostPosted: Fri Aug 24, 2007 10:09 pm 
Beginner
Beginner

Joined: Wed Sep 15, 2004 3:14 am
Posts: 35
Hi

I am trying to use enum type in one of my entities, but when I try to get the object, Hibnernate tells me there is an unknown name value for the enum type. Please help. Thanks.

Code:
@Entity
public class CreditCard {

    @Enumerated(EnumType.STRING)
    @Column(name = "type", nullable = false)
    private CreditCardType type;
    ...
}


Code:
public enum CreditCardType {

    MASTERCARD("Mastercard"),
    VISA("Visa"),
    AMEX("American Express");

    private final String cardType;

    private CreditCardType(String cardType) {
        this.cardType = cardType;
    }

    public String toString() {
        return cardType;
    }
}


Hibernate version: 3.2.3.ga

Name and version of the database you are using: PostgreSQL 8.2

Full stack trace of any exception that occurs:
Code:
java.lang.IllegalArgumentException: Unknown name value for enum class auction.model.CreditCardType: String
   at org.hibernate.type.EnumType.nullSafeGet(EnumType.java:104)
   at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:105)
   at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
   at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2046)
   at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1371)
   at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1299)
   at org.hibernate.loader.Loader.getRow(Loader.java:1197)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:568)
   at org.hibernate.loader.Loader.doQuery(Loader.java:689)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
   at org.hibernate.loader.Loader.loadCollection(Loader.java:1985)
   at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
   at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
   at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
   at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
   at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
   at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
   at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:109)
   at org.hibernate.collection.PersistentBag.size(PersistentBag.java:225)
   at auction.dao.CreditCardDAOTest.testFindById(CreditCardDAOTest.java:34)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at junit.framework.TestCase.runTest(TestCase.java:168)
   at junit.framework.TestCase.runBare(TestCase.java:134)


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

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.