JDO

742 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
742
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

JDO

  1. 1. 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 ) }
  2. 2. Transient Persistent-new Persistent-dirty Hollow Persistent-clean Persistent-deleted Persistent-new-deleted
  3. 3. http://java.sun.com/developer/technicalArticles/J2SE/jdo/fig2sm.gif
  4. 4. http://db.apache.org/jdo/images/state_transition_persist.gif
  5. 5. http://db.apache.org/jdo/images/state_transition_update.gif
  6. 6. http://db.apache.org/jdo/images/state_transition_delete.gif
  7. 7. @PersistenceCapable(...) @PersistenceCapable(...) class Parent class Child implements Serializable { implements Serializable{ @PrimaryKey @PrimaryKey @Persistent(...) @Persistent(...) Long id Key key @Persistent ... Child child } ... }
  8. 8. @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 ... ... } }
  9. 9. @PersistenceCapable(...) @PersistenceCapable(...) class Parent class Child implements Serializable { implements Serializable{ @PrimaryKey @PrimaryKey @Persistent(...) @Persistent(...) Long id Key key @Persistent ... List<Child> children } ... }
  10. 10. @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 ... ... } }
  11. 11. @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)

×