Hibernate のバックアップソース(No.5)


 HibernateはGNUのLGPLで公開、配布されているオープンソースのO/Rマッピングツールです。軽快な動作と実用性の高さでJDOの有力な対抗馬とされています。検索にはHQL(Hibernate Query Language)というSQLに似た独自の問い合わせ言語を使用する方法とオブジェクト指向な設定方法があります。サブクエリや集計関数もサポートするなど、JDOの問い合わせ言語であるJDOQLと比べるとかなり実用度が高いです。

-2004/8/23 - Hibernate 3.0 alphaリリース
--package rename net.sf.hibernate -> org.hibernate
--checked exceptions are now runtime exceptions
--some session methods deprecated and moved to org.hibernate.classic.Session
--removed various deprecated functionality
--added Filter API and mappings, for temporal, regional and permissioned data (Steve Ebersole, Gavin King)
--support cascade delete via ON DELETE CASCADE constraint
--added extra attributes to named query definition
--added hibernate.use_identifier_rollback
--added subselect mappings
--added lazy="true" to property mappings
--added <join/> for multitable mappings
--added <union-subclass/> for table-per-concrete-class strategy
--added Statistics API and JMX MBean (Gavin King, Emmanuel Bernard)
--introduced new event-driven design (Steve Ebersole)
--support for faster startup with Configuration.addCachableFile() (Max Andersen)
--mask connection password for log level greater of equals to info (Joris Verschoor, Emmanuel Bernard)
--add check of named queries when building SessionFactory (Joris Verschoor, Emmanuel Bernard)
--added custom EntityResolver setting capability (Emmanuel Ligne, Emmanuel Bernard)
--PropertyValueException for null values in not-null properties of components (Emmanuel Bernard)
--enhanced support for single- and no-argument sql-functions in HQL select clause (Michael Gloegl)
--Added catalog element, to enable table names like catalog.schema.table (Michael Gloegl)
--Added <sql-insert>, <sql-update> and <sql-delete> support (Max Andersen)
--Support callable statements (stored procedures/functions) via callable="true" on custom sql (Max Andersen)
--Added support for type parameters and typedefs (Michael Gloegl)
--Added support for JDBC escape sequences in createSQLQuery (Max Andersen)
--Added statistics per SessionFactory (Gavin King, Emmanuel Bernard)
--Added a StatisticsService MBean for JMX publucation (Emmanuel Bernard)
--support for updates via rownum in Oracle
--fixed problems with SchemaUpdate
--support for <column formula="..."/>
--added hibernate.use_sql_comments
--added property-ref to collection <key/>
--fixed performance problems with <one-to-one property-ref=.../>
--enhanced UserType with new methods assemble()/disassemble()
--better algorithm for batch fetch batch sizes
--added <dynamic-class>
--added entity-name concept, and session methods save(entityName, object), update(entityName, object), etc
--added framework in proxy package
--native SQL queries may now fetch a collection role
--added <loader/> for class and collection mappings
--added getEntity() and getEntityName() to Interceptor
--formula-based discriminators and association mappings
--added "guid" id generation strategy
--various improvements to dialects
--<discriminator force="true"/> now acts as a filter on collections
--where filters now apply in the on clause in an outer join

-2004/8/9 - Hibernate 2.1.6リリース
--fixed Quickstart/readme.txt instructions
--fixed DB2/400 identity column support
--fixed the scroll() query method
--fixed exotic classloader problems with CGLIB
--added insert="false" for discriminator columns which are part of a composite identifier
--added several new configuration settings to JMX HibernateService
--added new instantiate() method to SessionFactory.getClassMetadata()
--improved the HSQL DB dialect with features from new version


DB2,FrontBase,HSQLDB,informix,interbase,MS SQL server,MySQL, Oracle,Pointbase,PostgreSQL,Sybase etc.

-接続するDB毎のHibernate設定ファイル(プロパティファイル or XMLファイル)

-[[Working with Hibernate in Eclipse:]]

-[[JFaceDbc:]] - RDBのフロントエンドですが、Hibernate用ソースコード(JAVA,XML)の出力機能があります。
-[[Hibernator:]] - メタデータからテーブルを作成したり、HQLを発行して結果を確認したりできます。
-[[Hibernate Synchronizer:]] - 定義ファイルウィザード、ファイルの同期など。
-[[HiberClipse Plugin:]] - 定義ファイルの生成。

 package test;
 import java.util.List;
 import java.util.Properties;
 import net.sf.hibernate.Hibernate;
 import net.sf.hibernate.HibernateException;
 import net.sf.hibernate.Session;
 import net.sf.hibernate.Transaction;
 import net.sf.hibernate.cfg.Configuration;
 import net.sf.hibernate.expression.Expression;

 public class SampleMain {

     public static void main(String[] args) {
         Configuration cfg = null;
         Session session = null;
         Transaction transaction = null;
         Properties props = new Properties();

         try {
             cfg = new Configuration().addClass(Person.class).addProperties(props);
             session = cfg.buildSessionFactory().openSession();
             transaction = session.beginTransaction();

             Person person = new Person();

             // 追加の実行と生成されたIDの取得
             Long id = (Long);

             // 追加の確認(loadメソッド検索)
             Person load = (Person) session.load(Person.class, id);

             // 修正の実行

             // 修正の確認(HQLによるfindメソッド検索)
             List list = session.find("from Person where id=?", id, Hibernate.LONG);
             // 修正の確認(Expressionによるfindメソッド検索)
             List list2 =
                 session.createCriteria(Person.class).add(Expression.eq("id", id)).list();

             // 削除の実行

             // 削除の確認
             list = session.find("from Person");

             // SQLのコミット

         } catch (Exception e) {
             try {
                 if (transaction != null)
             } catch (Exception e1) {
         } finally {
             try {
                 if (session != null && session.isOpen())
             } catch (HibernateException e1) {

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
   <class name="test.Person" table="PERSON">
     <id name="id" column="ID" type="long">
       <generator class="native"/>
     <property name="name" column="NAME" type="string" length="20" not-null="true"/>

for update指定でselectした行をトランザクションの終了までロックする。~
(for update nowaitを指定する場合は、LockMode.UPGRADEをLockMode.UPGRADE_NOWAITに変える)
 Person load = (Person) session.load(Person.class, id, LockMode.UPGRADE);

 List list2 = session.createCriteria(Person.class)
                     .add(Expression.eq("id", id))

トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS

Modified by MT22(Moriwaki Takashi)

"PukiWiki" 1.3.7 Copyright © 2001,2002,2003 PukiWiki Developers Team. License is GNU/GPL.
Based on "PukiWiki" 1.3 by sng
Powered by PHP 5.3.29

HTML convert time to 0.019 sec.