Thomas,
On Tuesday, October 22, 2013 6:26:37 PM UTC+2, Thomas Broyer wrote:
-- thank you for your time and your Help. I will now migrate my application to Objectitfy.
I am sick of JPA and Datanucleus and I am not willing to continue jumping from one JPA problem into another. I hope Objectify will save me from this struggling with Datastore.
Many Many thanks for your help!
Nermin
On Tuesday, October 22, 2013 6:26:37 PM UTC+2, Thomas Broyer wrote:
On Tuesday, October 22, 2013 6:12:36 PM UTC+2, Nermin wrote:OK Thomas, I will go for Objectify.
The only problem is that I cannot find a really good tutorial for using it with Requestfactory.
http://code.google.com/p/objectify-appengine/wiki/ ObjectifyWithGWT
For example, their official GWT-Tutorial is totally confusing (see link above), they state: "Make sure your entity classes are part of your GWT module (typically in a .client package)." ...... Now I get totally confused! Is this really true?????They use GWT-RPC, so yes (your entities would be used on the client-side, so they'd have to be in .client or .shared – assuming you follow GWT's naming conventions here).It's not the case when you use RequestFactory.Have you looked at http://turbomanage.wordpress.com/2011/03/25/ ? (linked at the bottom of the above-linked page)using-gwt-requestfactory-with- objectify/ (from memory, it's a bit old, back in the days when Objectify didn't have a request-scoped cache, so it could break depending on the requests you made; but Objectify now has a request-scoped cache, so it should Just Work™; just beware of this: https://code.google.com/p/objectify-appengine/wiki/ , but if I understand correctly there are relatively few cases where it would break with RequestFactory).Caching#Transactions_and_the_ Session_Cache I have played today wit it a bit with Objectify, and I have managed it to create an simple working example.
Can you please tell me if this is the right way of working with the Objectify 4 and the RequestFactory?Heh, I never used Objectify either (I never worked with AppEngine), but I'll do my best.The code works but I am somehow not really sure if I am on the right track. Here is my code:
Btw: I have all my entities on server side.
@Entity
public class EntityOne {
@Id
private Long id;
private Integer version = 0;
private String name;
private Key<EntityTwo> entityTwoKey; //This is the Key for the EntityTwo (Using this you will know how to lad it)
@Ignore
private EntityTwo entityTwo; //Transient field (not saved in the Datastore) it is a real representation of the entityt
@OnSave
void onPersist() {
version++; // Increase the Version
}
// ========= HANDLER METHODS ==========//
public static EntityOne findEntityOne(Long id) {
return ofy().load().type(EntityOne.class).id(id).now();
}
public void persist() {
ofy().save().entity(this).now();
}
....
public Key<EntityTwo> getEntityTwoKey() {
return entityTwoKey;
}
public void setEntityTwoKey(Key<EntityTwo> entityTwoKey) {
this.entityTwoKey = entityTwoKey;
}
public EntityTwo getEntityTwo() {
//Load entity using its Key
this.entityTwo = ofy().load().key(getEntityTwoKey()).now();
return this.entityTwo;
}
public void setEntityTwo(EntityTwo entityTwo) {
//Step1: Set the key (This will make sure it be saved into the DB)
this.entityTwoKey = Key.create(EntityTwo.class, entityTwo.getId());
//Step2: Set entity
this.entityTwo = entityTwo;
}
}
@Entity
public class EntityTwo {
@Id
private Long id;
private Integer version = 0;
private String name;
@OnSave
void onPersist() {
version++; // Increase the Version
}
// ========= HANDLER METHODS ==========//
public static EntityTwo findEntityTwo(Long id) {
return ofy().load().type(EntityTwo.class).id(id).now();
}
public EntityTwo persist() {
ofy().save().entity(this).now();
return this;
}
... Get/set
}
@ProxyFor(EntityOne.class)
public interface EntityOneProxy extends EntityProxy {
Long getId();
Integer getVersion();
void setVersion(Integer version);Do you really want to get/set the version on the client-side? (OK, get the version maybe, but set it?)String getName();
void setName(String name);
EntityTwoProxy getEntityTwo();
void setEntityTwo(EntityTwoProxy entityTwo);
}
@ProxyFor(EntityTwo.class)
public interface EntityTwoProxy extends EntityProxy {
Long getId();
Integer getVersion();
void setVersion(Integer version);
String getName();
void setName(String name);
}
... And registering to my RequestFactory interface ... etc.
Is this code OK??It looks OK to me.
If I understood correctly, I do not need to care about OSIV etc.Yes, except https://code.google.com/p/objectify-appengine/ as already mentioned.wiki/Caching#Transactions_and_ the_Session_Cache All I need to do is to register ObjectifyFilter. Right?It seems so.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment