Weitere ähnliche Inhalte
Mehr von Kiyotaka Oku (8)
Kürzlich hochgeladen (20)
JDO
- 7. def jdoTemplate
def transactionTemplate
def save = {
transactionTemplate.execute( { status ->
def album = new Album(params)
if(!album.hasErrors() && album.validate() ) {
jdoTemplate.makePersist(album)
flash.message = "Album ${albumInstance.id} created"
redirect(action:show,id:album.id)
}
else {
status.setRollbackOnly()
render(view:'create',model:[album:album])
}
} as TransactionCallback ) }
- 17. @PersistenceCapable(...) @PersistenceCapable(...)
class Parent class Child
implements Serializable { implements Serializable{
@PrimaryKey @PrimaryKey
@Persistent(...) @Persistent(...)
Long id Key key
@Persistent ...
Child child }
...
}
- 18. @PersistenceCapable(...) @PersistenceCapable(...)
class Parent class Child
implements Serializable { implements Serializable{
@PrimaryKey @PrimaryKey
@Persistent(...) @Persistent(...)
Long id Key key
@Persistent @Persistent(mappedBy='child')
Child child Parent parent
... ...
} }
- 19. @PersistenceCapable(...) @PersistenceCapable(...)
class Parent class Child
implements Serializable { implements Serializable{
@PrimaryKey @PrimaryKey
@Persistent(...) @Persistent(...)
Long id Key key
@Persistent ...
List<Child> children }
...
}
- 20. @PersistenceCapable(...) @PersistenceCapable(...)
class Parent class Child
implements Serializable { implements Serializable{
@PrimaryKey @PrimaryKey
@Persistent(...) @Persistent(...)
Long id Key key
@Persistent(mappedBy='parent') @Persistent
List<Child> children Parent parent
... ...
} }
- 21. @PersistenceCapable(...) @PersistenceCapable(...)
class A class B
implements Serializable { implements Serializable {
@PrimaryKey @PrimaryKey
@Persistent(...) @Persistent(...)
Key key Key key
@Persistent @Persistent
Set<key> bKeys Set<Key> aKeys
... ...
} }
def a = persistenceManager.getObjectById(...)
def bList = persistenceManager.getObjectsById(a.bKeys)