I'm absolutly new in JDO. I'm trying to relate houses and counties.
For counties I have this class:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class County {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private String idCounty;
@Persistent private String name;
public Prov(String id, String name) {
this.idCounty = id;
this.name = name;
}
...
}
For houses I have this class:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class House {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long idHouse;
@Persistent private String title;
@Persistent private Integer price;
@Persistent private Key county; //// this is how the gae tutorial
recomends to do it
...
public void setCounty(County county) {
this.prov = KeyFactory.stringToKey(prov.getCodProv()); //// this
is how I thought I could get the key AND this is the point where it
throws the exception
}
...
}
And thats the code that throws the
County county = new County("46", "Valencia");
pm.makePersistent(county);
House house = ...
house.setCounty(county);
pm.makePersistent(house);
That's what I get:
java.lang.IllegalArgumentException: Invalid Key PB: no elements.
Thank you in advance.
--
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.