Meaningless Drivel is fun!*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem with Enums" Watch "Problem with Enums" New topic
Author

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: http://aspose.com/file-tools
 
subject: Problem with Enums
 
Similar Threads
Caused by: java.sql.SQLException: Statement parameter 2 not set.
Composite foreign key causing "object is not an instance of declaring class"?
NonUnique Object Exception
ejb3 primary key generation does not work without automatic schema generation
PersistentObjectException: detached entity passed to persist: