Skip to main content

@Enumerated?

10 replies [Last post]
cayhorstmann
Offline
Joined: 2003-06-13

I just read about @Enumerated in the EJB3 persistence spec (section 9.1.19) and was eager to try it out. Unfortunately, GlassFish build 32 doesn't seem to support it yet. I'd be grateful for any insight when that might be available.

Thanks,

Cay

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
trouby
Offline
Joined: 2006-02-27

Hey,

I Have the exact problem as the last response,

Any news about this? same code works on Hibernate smoothly,

Thanks

isana
Offline
Joined: 2005-11-10

Hello,

The new release B47 still has this problem.

Thanks.
- Ryosuke

ss141213
Offline
Joined: 2005-03-30

Have you filed a bug?

Sahoo

isana
Offline
Joined: 2005-11-10

Hello, Sahoo

No I didn't, yet. I'm not enough familiar with the rules of java.net, so I myself wondered whether I can (should) file bugs.

I'm going to file this later.

Thanks,
- Ryosuke.

ss141213
Offline
Joined: 2005-03-30

First login to http://glassfish.dev.java.net site using your java.net id and then you can file bugs accessing following URL:
https://glassfish.dev.java.net/issues/enter_bug.cgi

isana
Offline
Joined: 2005-11-10

Hello,

I filed a bug. See the issue #634: https://glassfish.dev.java.net/issues/show_bug.cgi?id=634

Thanks,
- Ryosuke.

isana
Offline
Joined: 2005-11-10

Hello,

For your information :
This problem is caused by the issue #193 : https://glassfish.dev.java.net/issues/show_bug.cgi?id=193
See #634 for detail.

Thanks,
- Ryosuke.

lucduponcheel
Offline
Joined: 2004-06-14

Personally I ran into problems using @Enumerated(ORDINAL) or @Enumerated(STRING) in combination with ejb-ql.

The enum information is stored like expected in the database,
but when querying the database the glassfish error log tells me that there is no conversion defined.

I do not know if this is a known bug, if not, then
I can file it (I have a complete simple ant project
that shows the issue)

isana
Offline
Joined: 2005-11-10

Hello,

I'm encountering the same problem.

My application has a class with a property annotated with @Enumerated :
---
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Level level; // <- Level is an enum.
---

And an exception is thrown with the attached stacktrace, when I flush the EntityManager after a new instance of entity Bar created. Simplified relations between entity objects is as follows:

---
public enum Level {LEVEL_A,...}

@Entity public class Bar {
...
@Enumerated(EnumType.STRING) @Column(nullable = false) private Level level;
}
---

And the code around the exception point is like this :
---
bar = new Bar();
bar.setLevel(Level.LEVEL_A);
...
em.persist(bar);
em.flush(); // <-- The exception is thrown here.
---

If I changed the persistent property's type from Level to String and added codes to convert between Level values and String, the application worked properly.

Any help is appreciated.

Best regards,
- Ryosuke

---- Stacktrace
Caused by: javax.persistence.PersistenceException: Exception [TOPLINK-115] (Oracle TopLink Essentials - 2006.4 (Build 060412)): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: No conversion value provided for the attribute [LEVEL_A].
Mapping: oracle.toplink.essentials.mappings.DirectToFieldMapping[level-->MY_APP.BAR.LEVEL]
Descriptor: RelationalDescriptor(my.package.model.Bar --> [DatabaseTable(MY_APP.BAR)])
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.flush(EntityManagerImpl.java:272)
at com.sun.enterprise.util.EntityManagerWrapper.flush(EntityManagerWrapper.java:509)
at my.package.control.EntityManagerWrapper.flush(EntityManagerWrapper.java:129)
... 27 more
Caused by: Exception [TOPLINK-115] (Oracle TopLink Essentials - 2006.4 (Build 060412)): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: No conversion value provided for the attribute [LEVEL_A].
Mapping: oracle.toplink.essentials.mappings.DirectToFieldMapping[level-->MY_APP.BAR.LEVEL]
Descriptor: RelationalDescriptor(my.package.model.Bar --> [DatabaseTable(MY_APP.BAR)])
at oracle.toplink.essentials.exceptions.DescriptorException.noAttributeValueConversionToFieldValueProvided(DescriptorException.java:943)
at oracle.toplink.essentials.mappings.converters.ObjectTypeConverter.convertObjectValueToDataValue(ObjectTypeConverter.java:224)
at oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping.getFieldValue(AbstractDirectMapping.java:446)
at oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRow(AbstractDirectMapping.java:715)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRow(ObjectBuilder.java:723)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRow(ObjectBuilder.java:711)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:425)
at oracle.toplink.essentials.queryframework.InsertObjectQuery.executeCommit(InsertObjectQuery.java:74)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedWrite(DatabaseQueryMechanism.java:635)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedInsert(DatabaseQueryMechanism.java:599)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:495)
at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeCommitWithChangeSet(WriteObjectQuery.java:130)
at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:283)
at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:67)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:536)
at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:123)
at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:95)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2211)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:894)
at oracle.toplink.essentials.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:254)
at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsForClassWithChangeSet(CommitManager.java:231)
at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:187)
at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2643)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1023)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:353)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkImpl.java:1139)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:231)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.flush(EntityManagerImpl.java:268)
... 29 more
----

guypelletier
Offline
Joined: 2005-10-19

Hi Cay,

Support for @Enumerated will be in the next promoted build.

Cheers,
Guy