
![]()
As I twitted last week I am testing an early version of Google’s App Engine in Java flavor. If you never got the chance to try it, or you are just curious about it, I wrote a few tutorials about how to do regular things, including: java patters, servlets, data access, etc.
Use this command to anonymously check out the latest project source code:
Example 1 – Using DataStore nad JPA
I created a POJO calle SimplePojo and stored un DS using JPA. Below is a copy of the persistance.xml file I am using…
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="transactions-optional">
<provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
<class>com.gae.tutorial.pojo.SimplePojo</class>
<properties>
<property name="datanucleus.NontransactionalRead" value="true"/>
<property name="datanucleus.NontransactionalWrite" value="true"/>
<property name="datanucleus.ConnectionURL" value="appengine"/>
</properties>
</persistence-unit>
</persistence>
Note the the hardcoded appengie value from the connection URL. Below the Poj file…
import javax.jdo.annotations.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@Entity
@Table(name = "simple_pojo")
@NamedQueries( {
@NamedQuery(name = "getLast", query = "SELECT p FROM SimplePojo p ORDER BY p.id DESC")
})
public class SimplePojo {
@Id
@GeneratedValue(generator="generador",strategy=GenerationType.IDENTITY)
@Column(name="ID")
private Long id;
@Column(name="VALOR")
private String valor;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getValor() {
return valor;
}
public void setValor(String valor) {
this.valor = valor;
}
}
To fully understand this example I recommend you to checkout the SVN source repo and open it on eclipse. One important thing is that you need to install the App Engine SDK for Java and the eclipse plugins from App Engine too.
Also recommend you to get an account and start uusing it.!
Cheers!
Leandro.

Kostya on June 19th, 2010 at 12:24 says:
?????? ????! jose@tehnon.ru” rel=”nofollow”>……
? ??….
Konstantin on June 19th, 2010 at 14:04 says:
?????? ?????! mason@sportbul.ru” rel=”nofollow”>……
? ?????????,…
TRAVIS on July 21st, 2010 at 05:50 says:
Buy:Lumigan.Synthroid.Arimidex.100% Pure Okinawan Coral Calcium.Actos.Mega Hoodia.Prevacid.Valtrex.Zyban.Prednisolone.Human Growth Hormone.Petcam (Metacam) Oral Suspension.Nexium.Accutane.Zovirax.Retin-A….