Buy anything from HongKong - Dealextreme

You can buy any kind of electronic gadgets from DealExtreme with free shipping option.
Please visit DealExtreme for very low prices.
Here is the link to the site : www.dealextreme.com

29 August 2007

Persistence Framework for J2ME

Floggy is a free object persistence framework for J2ME/MIDP applications.
http://floggy.sourceforge.net/

import net.sourceforge.floggy.persistence.Persistable;
public class Person implements Persistable {
// Static fields aren't persisted
public static int SOME_STATIC_FIELD = 1;

private String name;
private Date birthday;
private char gender;

// Transient fields aren't persisted
private transient int age;

// Each persistable class must have an empty constructor.
public Person() {
// Do something ...
}

...
}


-------------------------------------------------

Person p = new Person();
p.setName(...);
p.setBirthday(...);
p.setGender(...);
try {
// A new object ID is generated.
// You can use it in future operations.
int id = PersistableManager.getInstance().save(p);
} catch (FloggyException e) {
...
}


------------------------------------------------

Person person = new Person();
try {
// To load an object, use the object ID
// generated previously by a save() operation.
PersistableManager.getInstance().load(person, id);
// Now, edit and save the object.
// The same object ID is returned.
person.setName(...);
id = PersistableManager.getInstance().save(person);
} catch (FloggyException e) {
...
}


--------------------------------------------------

No comments: