File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Problem with Enums Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem with Enums" Watch "Problem with Enums" New topic

Problem with Enums

Ra Carter
Ranch Hand

Joined: Jul 30, 2005
Posts: 96
i am using maven's jpa-maven-archetype with eclipse to build my first EJB 3.0/JPA project. i am having a problem mapping an enum to the database though. my enum use is simple enough:

when i build with maven and test, i get this:

i'm not really sure if it matters but since i am relying on maven to do some of the dirty work that i dont yet understand, this is the dependencies in my pom.xml file in case i have done something wrong there:

finally, my persistence.xml file looks like this:

also, is it possible to map an enum to a reference table? So that instead of the enum value by ordinal or string it would join to some other table that had the constant definitions mapped to some number?

one other question i have about all this is that if i remove the enum variable then everything seems to work except the price value in my Anvil class shows up as double in the mysql database and the precision or scale does not get defined. why is that?
Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
Originally posted by Ra Carter:

To me, this looks more like an issue with a generated ID than with an enum.
In any case, it would help to see the ID mapping within the class and the code that inserts the object.
[ November 26, 2007: Message edited by: Edvins Reisons ]
I agree. Here's the link:
subject: Problem with Enums
It's not a secret anymore!