SlideShare a Scribd company logo
1 of 14
Download to read 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に
関する記事が掲載。
精読してね><
             はセリ自重
壮大な
前フリ終了

More Related Content

What's hot (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)
 

Similar to 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
 

Similar to 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紹介
 

More from 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
 

Recently uploaded

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 

Recently uploaded (20)

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
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
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 

GAE/J 開発環境でJDO入門