|
Project Information
Featured
Downloads
|
An xml persistence layer written using XStream to persist java objects in a very simple fashion. All that is currently required is that the object has an ID field identified with an @Id annotation, and it can be persisted and loaded separately from associated objects.
Example (see tests for more): import org.corbym.simplex.persistence.annotations.Id
...
class SomeObjectWithId(){
@Id
def id
}
...
class SomeObjectWithDefFieldAndId{
@Id
def id
def somefield
}
...
final idObject = new SomeObjectWithId()
final someObject = new SomeObjectWithDefFieldAndId(somefield: ["thingy": idObject])
someObject.somefield.put "thing2", new SomeObjectWithoutId()
dao.save(someObject)
assert someObject.id != null
assert idObject.id != null
def loaded = dao.load(SomeObjectWithId, idObject.id)
assert loaded, "object should be loaded but was $loaded"
def otherThatContainedIdObject = dao.load(SomeObjectWithDefFieldAndId, someObject.id)
assert otherThatContainedIdObject.somefield.values().size() == 2
Dependencies: |