My bad. Thanks for noticing, but that's not the problem. I don't 
actually call it Enumv, I call it EnumTrait, and I just failed to change 
it back in the email.

Jorge Ortiz wrote:
> I don't really know much about JPA, but just a quick observation on the 
> code you posted:
> 
> Your code has line:
>   abstract class EnumvType(val et: Enumeration with EnumTrait) extends 
> UserType {
> whereas JPA Demo has line:
>   abstract class EnumvType(val et: Enumeration with Enumv) extends 
> UserType {
> 
> I don't know what your EnumTrait is, or whether it might be causing the 
> problem, but it's worth noting.
> 
> One thing I can do is release a version of 0.10 that compiles against 
> Scala 2.7.2 and rolls back the minor changes made to Lift to compile 
> against 2.7.2. But I don't know how David et al feel about this.
> 
> --j
> 
> On Thu, Jan 22, 2009 at 3:16 PM, Charles F. Munat <c...@munat.com 
> <mailto:c...@munat.com>> wrote:
> 
> 
>     I have an entity thus:
> 
>     @Entity
>     @Table{val name = "cocktails"}
>     class Cocktail extends BaseEntity {
>       @Id
>       @GeneratedValue{val strategy = GenerationType.AUTO}
>       var id : Long = _
> 
>       var name : String = ""
> 
>       var description : String = ""
> 
>       var ingredients : String = ""
> 
>       @Column{val name = "file_name"}
>       var fileName : String = ""
> 
>       @Column{val name = "is_archived"}
>       var isArchived : Boolean = false
> 
>       @Type{val `type` = "com.xxx.model.CocktailGroupType"}
>       @Column{val name="cocktail_group"}
>       var cocktailGroup: CocktailGroup.Value = CocktailGroup.Originals
>     }
> 
> 
> 
>     Which uses this enumeration:
> 
>     object CocktailGroup extends Enumeration with Enumv {
>       val Originals = Value("Originals")
>       val Contemporaries = Value("Contemporaries")
>       val Classics = Value("Classics")
>       val Others = Value("Others")
>     }
> 
>     class CocktailGroupType extends EnumvType(CocktailGroup) {}
> 
> 
> 
>     Which is queried thus in orm.xml:
> 
>     <named-query name="findCocktailsByGroup">
>       <query><![CDATA[from Cocktail c
>         where c.isArchived = false
>         and c.cocktailGroup = :cocktailGroup
>         order by c.name <http://c.name>]]></query>
>     </named-query>
> 
> 
> 
>     And called from CocktailOps.scala:
> 
>     120: val cocktails = Model.createNamedQuery[Cocktail](
>            "findCocktailsByGroup",
>            "cocktailGroup" -> "Originals").findAll
> 
> 
> 
>     Using Enumv:
> 
>     trait Enumv  {
> 
>       this: Enumeration =>
> 
>       private var nameDescriptionMap =
>         scala.collection.mutable.Map[String, String]()
> 
>       def Value(name: String, desc: String) : Value = {
>         nameDescriptionMap += (name -> desc)
>         new Val(name)
>       }
> 
>       def getDescriptionOrName(ev: this.Value) = {
>         try {
>           nameDescriptionMap(""+ev)
>         } catch {
>           case e: NoSuchElementException => ev.toString
>         }
>       }
> 
>       def getNameDescriptionList =  this.elements.toList.map(
>         v => (v.toString, getDescriptionOrName(v) ) ).toList
>     }
> 
> 
> 
>     And EnumvType:
> 
>     abstract class EnumvType(val et: Enumeration with EnumTrait)
>       extends UserType {
> 
>       val SQL_TYPES = Array({Types.VARCHAR})
> 
>       override def sqlTypes() = SQL_TYPES
> 
>       override def returnedClass = classOf[et.Value]
> 
>       override def equals(x: Object, y: Object): Boolean = {
>         return x == y
>       }
> 
>       override def hashCode(x: Object) = x.hashCode
> 
>       override def nullSafeGet(resultSet: ResultSet,
>                                names: Array[String],
>                                owner: Object): Object = {
>         val value = resultSet.getString(names(0))
>         if (resultSet.wasNull()) return null
>         else {
>           return et.valueOf(value)
>         }
>       }
> 
>       override def nullSafeSet(statement: PreparedStatement,
>                                value: Object,
>                                index: Int): Unit = {
>         if (value == null) {
>           statement.setNull(index, Types.VARCHAR)
>         } else {
>           val en = value.toString
>           statement.setString(index, en)
>         }
>       }
> 
>       override def deepCopy(value: Object): Object = value
> 
>       override def isMutable() = false
> 
>       override def disassemble(value: Object) =
>         value.asInstanceOf[Serializable]
> 
>       override def assemble(cached: Serializable, owner: Object):
>         Serializable = cached
> 
>       override def replace(original: Object,
>                            target: Object,
>                            owner: Object) = original
> 
>     }
> 
> 
>     Which gets me this error:
> 
>     Exception occured while processing /drinks/
> 
>     Message: javax.persistence.PersistenceException:
>     org.hibernate.PropertyAccessException: could not set a field value by
>     reflection setter of com.xxx.model.Cocktail.cocktailGroup
>          
>      
> org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630)
>            org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:75)
>            com.xxx.model.ScalaQuery.getResultList(JPA.scala:82)
>            com.xxx.model.ScalaQuery.findAll(JPA.scala:77)
>            com.xxx.snippet.CocktailOps.originals(CocktailOps.scala:120)
> 
> 
> 
> 
>     I have tried everything I can think of. This used to work before the
>     recent switch to 2.7.3. Can anyone spot the problem?
> 
>     Thanks. Website down. Am really screwed here.
> 
>     Chas.
> 
> 
> 
> 
> > 

--~--~---------~--~----~------------~-------~--~----~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to