SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
GAE/J 開発環境でJDO入門
~5分で出来るとこまで編 for LT~




        bose.techie.jp
JDOってなんなんだよ><

vGAE/Jでアプリを作る時に提供されてるのは
 RDBではなくてBigTableってやつ。
 それをあれこれするAPIがJDOやJPAなんだ。
 § JDOやJPAは標準的なものだからね!
   GAE/J独自じゃないよ!
はいー どーん




開発環境
  の
 作り方
開発環境構築の参考URL




     画像自重

http://gihyo.jp/dev/column/01/java/2009/0415
 あたり読むといいと思うよ。自習してくれ!
こんなこと言われないように><




 はセリ自重
本題ですよー



 今日はJDOって
どうやって書くのを
 中心にささっと
  紹介します。
まずEntity

@PersistenceCapable(                                GAE/Jでは必須
   identityType = IdentityType.APPLICATION)            アプリで
                                                     主キー定義する
public class User {
                                                      という意味

   @PrimaryKey
   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
   private Key key;

   @Persistent                                アプリケーションで
   private String userId;                      値を自動生成

   @Persistent
   private String password;

あとげったー、せったーね。
んで Daoね その1

public class UserDao {

  public void insert(PersistenceManager pm, User user){
     pm.makePersistent(user);
  }

  public void update(PersistenceManager pm, User user){
     insert(pm, user);
  }

  public User selectKey(PersistenceManager pm, Key key){
    return (User)pm.getObjectById(User.class, key);
  }

  public void delete(PersistenceManager pm, User user){
     pm.deletePersistent(user);
  }
んで Daoね その2

    public User selectUserId(PersistenceManager pm, String userId){

        Query query = pm.newQuery(User.class);
        query.declareParameters(quot;java.lang.String userIdquot;);
        query.setRange(0, 10);

         try {
             List<User> users = (List<User>) query.execute(userId);
             If(users != null && users.size() > 0){
                return users.get(0);
             } else {
                return null;
             }
        } finally {
          query.closeAll();
        }
    }
}
じゃあ 使うよ

User user = new User();
                                                   エンティティの操作を
user.setUserId(quot;pekoquot;);
user.setPassword(quot;pokopen!quot;);                     行う為のインタフェース
PersistenceManager persistenceManager =
    PMFactory.getPersistenceManager();
Transaction transaction = persistenceManager.currentTransaction();
transaction.begin();
try {                                                  トランザクション開始
   UserDao userDao = new UserDao();
   userDao.insert(persistenceManager,user);                    データ永続化
   user = userDao.selectUserId(persistenceManager,quot;pekoquot;);
   userDao.delete(persistenceManager,user);
   transaction.commit();
} catch (Exception e) {
                                                          データ検索
   e.printStackTrace();
} finally {
   if (transaction.isActive()){
                                                       データ削除
       transaction.rollback();
   }
                                                    トランザクションコミット
   persistenceManager.close();
}
                                               トランザクションロールバック
はセリ自重
はーい 注目! ここでCMです!

WEB+DB PRESSに
グルージェント荒川大先生の
BigTable/JDOに
関する記事が掲載。
精読してね><
             はセリ自重
壮大な
前フリ終了

Mais conteúdo relacionado

Mais procurados (10)

20090418 イケテルRails勉強会 第2部Air編 解説
20090418 イケテルRails勉強会 第2部Air編 解説20090418 イケテルRails勉強会 第2部Air編 解説
20090418 イケテルRails勉強会 第2部Air編 解説
 
20090410 Gree Opentech Main
20090410 Gree Opentech Main20090410 Gree Opentech Main
20090410 Gree Opentech Main
 
C E N T R A R E L´ I M M A G G I N E
C E N T R A R E  L´ I M M A G G I N EC E N T R A R E  L´ I M M A G G I N E
C E N T R A R E L´ I M M A G G I N E
 
20090323 Phpstudy
20090323 Phpstudy20090323 Phpstudy
20090323 Phpstudy
 
Shibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼうShibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼう
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识
 
4200 Kte7.0 Training V1.0
4200 Kte7.0 Training V1.04200 Kte7.0 Training V1.0
4200 Kte7.0 Training V1.0
 
1 b1499reqts
1 b1499reqts1 b1499reqts
1 b1499reqts
 
【12-B-4】 並列処理開発を支援するコンパイラの機能
【12-B-4】 並列処理開発を支援するコンパイラの機能【12-B-4】 並列処理開発を支援するコンパイラの機能
【12-B-4】 並列処理開発を支援するコンパイラの機能
 
Windows 7兼容性系列课程(2):Windows 7用户权限控制 (UAC)
Windows 7兼容性系列课程(2):Windows 7用户权限控制 (UAC)Windows 7兼容性系列课程(2):Windows 7用户权限控制 (UAC)
Windows 7兼容性系列课程(2):Windows 7用户权限控制 (UAC)
 

Semelhante a GAE/J 開発環境でJDO入門

Sc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク DomaSc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク Doma
Toshihiro Nakamura
 
Ohp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 MojiretsuOhp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 Mojiretsu
sesejun
 
20090313 Cakephpstudy
20090313 Cakephpstudy20090313 Cakephpstudy
20090313 Cakephpstudy
Yusuke Ando
 
事件模型探究
事件模型探究事件模型探究
事件模型探究
ematrix
 
Open Source Type Pad Mobile
Open Source Type Pad MobileOpen Source Type Pad Mobile
Open Source Type Pad Mobile
Hiroshi Sakai
 
JSplash - Adobe MAX 2009
JSplash - Adobe MAX 2009JSplash - Adobe MAX 2009
JSplash - Adobe MAX 2009
gyuque
 
IE-027 動作與時間研究建立精實生產環境
IE-027 動作與時間研究建立精實生產環境IE-027 動作與時間研究建立精實生產環境
IE-027 動作與時間研究建立精實生產環境
handbook
 

Semelhante a GAE/J 開発環境でJDO入門 (20)

樽家昌也 (日本Rubyの会)
樽家昌也 (日本Rubyの会) 樽家昌也 (日本Rubyの会)
樽家昌也 (日本Rubyの会)
 
Sc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク DomaSc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク Doma
 
【13 C 2】デベロッパーに贈る!M-V-VMパターンで造るWPFアプリケーション
【13 C 2】デベロッパーに贈る!M-V-VMパターンで造るWPFアプリケーション【13 C 2】デベロッパーに贈る!M-V-VMパターンで造るWPFアプリケーション
【13 C 2】デベロッパーに贈る!M-V-VMパターンで造るWPFアプリケーション
 
Ohp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 MojiretsuOhp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 Mojiretsu
 
20090313 Cakephpstudy
20090313 Cakephpstudy20090313 Cakephpstudy
20090313 Cakephpstudy
 
Apache Tapestry
Apache TapestryApache Tapestry
Apache Tapestry
 
事件模型探究
事件模型探究事件模型探究
事件模型探究
 
object-shapes
object-shapesobject-shapes
object-shapes
 
Open Source Type Pad Mobile
Open Source Type Pad MobileOpen Source Type Pad Mobile
Open Source Type Pad Mobile
 
20090418 イケテルRails勉強会 第2部Air編
20090418 イケテルRails勉強会 第2部Air編20090418 イケテルRails勉強会 第2部Air編
20090418 イケテルRails勉強会 第2部Air編
 
Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信
Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信
Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信
 
JSplash - Adobe MAX 2009
JSplash - Adobe MAX 2009JSplash - Adobe MAX 2009
JSplash - Adobe MAX 2009
 
IE-027 動作與時間研究建立精實生產環境
IE-027 動作與時間研究建立精實生產環境IE-027 動作與時間研究建立精實生產環境
IE-027 動作與時間研究建立精實生產環境
 
ブラウザでMap Reduce風味の並列分散処理
ブラウザでMap Reduce風味の並列分散処理ブラウザでMap Reduce風味の並列分散処理
ブラウザでMap Reduce風味の並列分散処理
 
PHP超入門@LL温泉
PHP超入門@LL温泉PHP超入門@LL温泉
PHP超入門@LL温泉
 
Windows PowerShell V2 の新機能
Windows PowerShell V2 の新機能Windows PowerShell V2 の新機能
Windows PowerShell V2 の新機能
 
20090418 イケテルRails勉強会 第1部Rails編
20090418 イケテルRails勉強会 第1部Rails編20090418 イケテルRails勉強会 第1部Rails編
20090418 イケテルRails勉強会 第1部Rails編
 
Reloaded
ReloadedReloaded
Reloaded
 
Agileな開発現場での実践例
Agileな開発現場での実践例Agileな開発現場での実践例
Agileな開発現場での実践例
 
Grails紹介
Grails紹介Grails紹介
Grails紹介
 

Mais de bose999 (10)

PhoneGap de iOS develop
PhoneGap de iOS developPhoneGap de iOS develop
PhoneGap de iOS develop
 
Python hack-a-thon 2010-11 Enjoy survival !
Python hack-a-thon 2010-11 Enjoy survival !Python hack-a-thon 2010-11 Enjoy survival !
Python hack-a-thon 2010-11 Enjoy survival !
 
コンサルティングと私 Lightning Talk
コンサルティングと私 Lightning Talkコンサルティングと私 Lightning Talk
コンサルティングと私 Lightning Talk
 
JBoss Application Server 入門 ~ Seasar2を動かして見よう!~ on Seasar Conference 2009 White
JBoss Application Server 入門~ Seasar2を動かして見よう!~ on Seasar Conference 2009 WhiteJBoss Application Server 入門~ Seasar2を動かして見よう!~ on Seasar Conference 2009 White
JBoss Application Server 入門 ~ Seasar2を動かして見よう!~ on Seasar Conference 2009 White
 
Wicket + EJB3 on JBoss (Japanese)
Wicket + EJB3 on JBoss (Japanese)Wicket + EJB3 on JBoss (Japanese)
Wicket + EJB3 on JBoss (Japanese)
 
EJB3 ABC
EJB3 ABCEJB3 ABC
EJB3 ABC
 
something coin machine
something coin machinesomething coin machine
something coin machine
 
Quickly function add by Eclipse Monkey
Quickly function add by Eclipse MonkeyQuickly function add by Eclipse Monkey
Quickly function add by Eclipse Monkey
 
I leak the contents of my work.
I leak the contents of my work.I leak the contents of my work.
I leak the contents of my work.
 
JRuby on Rails on JBoss
JRuby on Rails on JBossJRuby on Rails on JBoss
JRuby on Rails on JBoss
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

GAE/J 開発環境でJDO入門