現在、Google App Engine がホストする Web サービスを使用するモバイル アプリケーションを開発しています。
しかし、私は問題に直面しています。データベースのテーブルにフィールドを追加したいだけです。App Engine は従来の SQL 構文ではなく、GQL を使用します。したがって、ALTER TABLE ステートメントを使用することはできません。GQLでこれを行うにはどうすればよいですか? Webで解決策を探しましたが、あまり助けがありません。
public MyEntity() {
}
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Key idStation;
private String name;
private double longitude;
private double latitude;
private java.util.Date dateRefresh = new Date(); //the field i want to add in DB
したがって、「MyEntity」オブジェクトを作成すると、「dateRefresh」フィールドがデータベースに追加されます...次のようにオブジェクトを作成します。
MyEntity station = new MyEntity();
station.setName("test");
station.setLatitude(0);
station.setLongitude(0);
station.setDateRefresh(new Date("01/01/1980"));
DaoFactory.getStationDao().addStation(station);
addStation メソッド:
@Override
public MyEntity addStation(MyEntity station) {
EntityManager em = PersistenceManager.getEntityManagerFactory().createEntityManager();
try {
em.getTransaction().begin();
em.persist(station);
em.getTransaction().commit();
} finally {
if(em.getTransaction().isActive()) em.getTransaction().rollback();
em.close();
}
return station;
}
フィールド「dateRefresh」がDBに作成されることはありません...
誰か助けてください。
前もって感謝します