Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
greenlaw110 committed Sep 14, 2010
1 parent 30598eb commit a3d5592
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ h2. Limitation
* "where" condition not support in the following interface of play.db.Model.Factory implementation:

bc.. public List<play.db.Model> fetch(int offset, int size, String orderBy, String order, List<String> searchFields, String keywords, String where);

p.
* The generic is not working well, sometimes you need type casting. If someone could help, that would be very appreciate.

Expand Down Expand Up @@ -219,7 +220,8 @@ h4. How to create Entity with user defined @Id field?
bc.. @Override public Object getId() {return name;}
@Override protected void setId_(Object id) {name = id.toString();}
protected static Object processId_(Object id) {return id.toString();}
p.

p..
* Make sure you always populated your @Id field before calling model.save(), don't let framework to generate Id for you b/c framework has no knowledge on how to do it
* It's better to keep your @Id field type to be java.lang.String.

Expand All @@ -228,7 +230,8 @@ h4. I got "Can not use dot-notation past ..." exception when I try to query ent
p. Basically this error occurred when you try to query an entity using referenced entity property. E.g. Post p = Post.filter("author.email", "bob@gmail.com").first(). The solution is:

bc.. User bob = User.filter("email", "bob@gmail.com").first();
Post p = Post.filter("author", bob).first();
Post p = Post.filter("author", bob).first();

p. If the relationship is embedded rather than reference, you can safely use "dot" notation to do the query

h4. How do I know if an entity object is an new object just constructed in the memory or represents a data (either by save or load from db) in a db?
Expand Down
19 changes: 17 additions & 2 deletions documentation/manual/home.textile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ h2. Limitation

bc.. public List<play.db.Model> fetch(int offset, int size, String orderBy, String order, List<String> searchFields, String keywords, String where);

p.
* The generic is not working well, sometimes you need type casting. If someone could help, that would be very appreciate.

* "Or" condition query is doable but the interface might changed in future, use it with caution.
Expand Down Expand Up @@ -216,9 +217,23 @@ h4. How to create Entity with user defined @Id field?

* Add @com.google.code.morphia.annotations.Id annotation to the field you want to use as an ID field, e.g. : @Id name;
* Override the following methods declared in play.modules.morphia.Model:
bc. @Override public Object getId() {return name;}
bc.. @Override public Object getId() {return name;}
@Override protected void setId_(Object id) {name = id.toString();}
protected static Object processId_(Object id) {return id.toString();}

p..
* Make sure you always populated your @Id field before calling model.save(), don't let framework to generate Id for you b/c framework has no knowledge on how to do it
* It's better to keep your @Id field type to be java.lang.String.
* It's better to keep your @Id field type to be java.lang.String.

h4. I got "Can not use dot-notation past ..." exception when I try to query entity using relationship, what happened?

p. Basically this error occurred when you try to query an entity using referenced entity property. E.g. Post p = Post.filter("author.email", "bob@gmail.com").first(). The solution is:

bc.. User bob = User.filter("email", "bob@gmail.com").first();
Post p = Post.filter("author", bob).first();

p. If the relationship is embedded rather than reference, you can safely use "dot" notation to do the query

h4. How do I know if an entity object is an new object just constructed in the memory or represents a data (either by save or load from db) in a db?

p. Use obj.isNew()

0 comments on commit a3d5592

Please sign in to comment.