I took a look at UserType and got the gist of what's going on, but it 
seems like a lot of work for very little gain. David's solution to just 
map the integer to the database will probably have to do for now.

Chas.

Viktor Klang wrote:
> Yo man,
> 
> all you've gotto do is to write your own UserType for Scala Enums 
> (please post it as Open Source for all to benefit)
> 
> Cheers,
> 
> Viktor
> 
> On Fri, Sep 19, 2008 at 11:03 PM, Charles F. Munat <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
> 
>     I'm still trying to get a Gender enumeration to work with JPA. The
>     problem now seems to be on the JPA end (I'm using the JPADemo code that
>     Derek provided).
> 
>     I get the following error:
>     javax.persistence.PersistenceException: org.hibernate.MappingException:
>     Could not determine type for: scala.Enumeration$Value, for columns:
>     [org.hibernate.mapping.Column(gender)]
> 
>     Here is the relevant code:
> 
> 
>     @serializable
>     object Gender extends Enumeration {
>       type Gender = Value
>       val Unknown = Value(0, "Unknown")
>       val Male = Value(1, "Male")
>       val Female = Value(2, "Female")
>     }
> 
>     import Gender._
> 
>     @Entity
>     @Table{val name = "USERS"}
>     class User {
>       @Id
>       @GeneratedValue{val strategy = GenerationType.AUTO}
>       var id : Long = _
> 
>       @Column{val name="NAME_LAST"}
>       var nameLast : String = ""
> 
>       @Column{val name="NAME_FIRST"}
>       var nameFirst : String = ""
> 
>       var username : String = ""
> 
>       @Column{val name="EMAIL_ADDRESS"}
>       var emailAddress : String = ""
> 
>       @Enumerated(EnumType.ORDINAL)
>       var gender : Gender = _
> 
>     ...
>     }
> 
>     Also, where is the best place to put the Gender enumeration so that it
>     is visible both in the persistence project and in the webapp?
> 
>     Thanks for any and all help.
> 
>     Chas.
> 
> 
> 
> 
> 
> -- 
> Viktor Klang
> Senior Systems Analyst
> 
> > 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to