You might want to ask on the Scala groups because I don't see a lot of Scala
questions asked on this group.

That being said, I've fiddled with Scala on App Engine before with some
success. A few tips from what I've learned:

- You don't need to create a Key. JDO will acquire a unique key for you.
Even with nanotime, there is a chance of a collision. You're doing
unnecessary work.
- The Persistent Annotation on Criteria may require a MappedBy parameter:
http://code.google.com/appengine/docs/java/datastore/relationships.html

In general, I've found that it makes more sense to define the data models
using Java, since sometimes the class enhancement works unexpectedly with
Scala generated bytecode.

On Sat, Feb 20, 2010 at 5:47 AM, Gero Vermaas <[email protected]> wrote:

> Hi,
>
> I'm have a parent-child relation between 2 classes, but the child
> objects are never stored. I do get an warning:
>
> "org.datanucleus.store.appengine.MetaDataValidator
> checkForIllegalChildField: Unable to validate relation
> net.vermaas.kivanotify.model.UserCriteria.internalCriteria"
>
> but it is unclear to me why this occurs. Already tried several
> alternatives without luck.
>
> The parent class is "UserCriteria" which has a List of "Criteria" as
> children.
>
> The classes are defined as follows (Scala):
>
> class UserCriteria(tu: String, crit: Map[String, String]) extends
> LogHelper {
>  @PrimaryKey
>  @Persistent{val valueStrategy = IdGeneratorStrategy.IDENTITY}
>  var id = KeyFactory.createKey("UserCriteria", System.nanoTime)
>
>  @Persistent
>  var twitterUser = tu
>
>  @Persistent
>  var internalCriteria: java.util.List[Criteria] = flatten(crit)
>
>  def flatten(crits: Map[String, String]) : java.util.List[Criteria] =
> {
>    val list = new java.util.ArrayList[Criteria]
>    for (key <- crits.keySet) {
>      list.add(new Criteria(this, key, crits(key)))
>    }
>    list
>  }
>
>  def criteria: Map[String, String] = {
>    val crits = mutable.Map.empty[String, String]
>
>    for (i <- 0 to internalCriteria.size-1) {
>      crits(internalCriteria.get(i).name) =
> internalCriteria.get(i).value
>    }
>
>    Map.empty ++ crits
>  }
>
>  // Stripped the equals, canEquals, hashCode, toString code to keep
> the code snippet short...
> }
>
> @PersistenceCapable
> @EmbeddedOnly
> class Criteria(uc: UserCriteria, nm: String, vl: String) {
>
>  @Persistent
>  var userCriteria = uc
>
>  @Persistent
>  var name = nm
>
>  @Persistent
>  var value = vl
>
>  override def toString = {
>    "Criteria name: " + name + " value: " + value
>  }
> }
>
> Any ideas why the childs are not stored? Or why I get the error
> message?
>
> Regards,
> Gero
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine
http://googleappengine.blogspot.com | http://twitter.com/app_engine

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to