<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-75  評論-193  文章-5  trackbacks-0
     

    EntityManager的定義

    The EntityManager manages the O/R mapping between a fixed set of entity classes and an underlying data source.
    It provides APIs for creating queries, finding objects, synchronizing objects, and inserting objects into the database.
    It also can provide caching and manage the interaction between an entity and transactional services in a Java EE environment such as JTA.
    The EntityManager is tightly integrated with Java EE and EJB but is not limited to this environment; it can be used in plain Java programs.

    An EntityManager maps a fixed set of classes to a particular database. This set of classes is called a persistence unit .

    In Java SE, entity managers are created using a javax.persistence.EntityManagerFactory
    Example:
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("titan", map);
        EntityManager manager = factory.createEntityManager();
    在Java SE環境中,使用完EntityManagerFactory后,最好將其關閉,以釋放其占有的資源。

    和Java SE環境不一樣,在Java EE中,一個注入的EntityManagerFactory會被EJB容器自動關閉,實際上,如果你調用EntityManagerFactory的clost()方法時,會拋出IllegalStateException異常。

    public interface EntityManager {
       public void persist(Object entity);
       public <T> T find(Class <T> entityClass, Object primaryKey);
       public <T> T getReference(Class <T> entityClass, Object primaryKey);
       public <T> T merge(T entity);
       public void remove(Object entity);
       public void lock(Object entity, LockModeType lockMode);

       public void refresh(Object entity);
       public boolean contains(Object entity);
       public void clear( );

       public void joinTransaction( );
       public void flush( );
       public FlushModeType getFlushMode( );
       public void setFlushMode(FlushModeType type);

       public Query createQuery(String queryString);
       public Query createNamedQuery(String name);
       public Query createNativeQuery(String sqlString);
       public Query createNativeQuery(String sqlString, String resultSetMapping);
       public Query createNativeQuery(String sqlString, Class resultClass);

       public Object getDelegate( );

       public void close( );
       public boolean isOpen( );
    }

    Persistence context的定義

    A persistence context is a set of managed entity object instances.
    Persistence contexts are managed by an entity manager.

    There are two types of persistence contexts: transaction-scoped and extended persistence contexts.

    A persistence context can be created by calling the EntityManagerFactory.createEntityManager( ) method. The returned EntityManager instance represents an extended persistence context. If the EntityManagerFactory is JTA-enabled, then you have to explicitly enlist the EntityManager instance within a transaction by calling the EntityManager.joinTransaction( ) method. If you do not enlist the EntityManager within the JTA transaction, then changes you make to your entities are not synchronized with the database.

    FlushModeType的含義

    FlushModeType默認為AUTO模式,當為AUTO時,在一個查詢被執行前,會自動將變化提交到數據庫中,即調用flush()方法。但是調用find()或getreference()方法時,并不會執行自動提交。當為COMMIT模式時,僅僅在事務提交時,會將變化提交到數據庫中。

    EJB3中的實體注解規范參見如下鏈接
    http://wiki.redsaga.com/confluence/display/HART/Home

    posted @ 2007-05-07 23:42 The Matrix 閱讀(597) | 評論 (0)編輯 收藏
    1、查找數組中的元素可以使用ascb.util.ArrayUtilities中的findMatchIndex()、findLastMatchIndex()、findMatchIndices()方法,具體參考API。

    2、使用splice()方法可以移除數組中間的元素,使用pop()方法移除數組的最后一個元素,使用shift()方法移除數組的第一個元素。也可以使用splice()方法向數組中增加元素。

    3、將數組轉化為String,可以使用join()方法。
    例:
    var letters:Array = ["a", "b", "c"];
    trace(letters.join());   // Displays: a,b,c
    posted @ 2007-01-16 22:35 The Matrix 閱讀(767) | 評論 (0)編輯 收藏
    flash.system.Capabilities類提供了很多靜態方法返回運行flash的player、計算機的信息,比如操作系統、語言、聲音、視頻能力等。
    還有一些其它的類比如:
    flash.display.Stage和flash.system.Security允許你控制播放器的右鍵彈出菜單和設置對話框。
    flash.display.Stage還可以控制播放器播放的視頻的縮放比例和位置。
    flash.system.Capabilities.os 返回操作系統信息。代碼如下:  

        var os:String = System.capabilities.os.substr(0, 3);
        if (os == "Win") {
            // Windows-specific code goes here
        } else if (os == "Mac") {
            // Mac-specific code goes here
        } else {
            // Must be Unix or Linux
        }

    flash.system.Capabilities.playerType   不同的類型包括:
        Browser plug-in that runs in web browsers such as Mozilla or Firefox
        ActiveX Control used by Internet Explorer    
        Standalone player, which plays .swfs outside of the browser     
        External player, which is the player integrated in the Flash IDE   

    flash.system.capabilities.screenResolutionX 和 screenResolutionY獲取屏幕分辨率。
    stage.scaleMode屬性可以設置一個movie如何填充播放器,包括比例等。
    有四種模式,以靜態常量的方法定義在flash.display.StageScaleMode類中,分別為:EXACT_FIT、NO_BORDER、NO_SCALE、SHOW_ALL。

    stage.align屬性可以設置一個movie的排列方式,也以靜態常量的方式定義在flash.display.StageAlign類中。
        如下:
                                  Vertical   Horizontal
       StageAlign.TOP              Top         Center
       StageAlign.BOTTOM           Bottom      Center
       StageAlign.LEFT             Center      Left
       StageAlign.RIGHT            Center      Right
       StageAlign.TOP_LEFT         Top         Left
       StageAlign.TOP_RIGHT        Top         Right
       StageAlign.BOTTOM_LEFT      Bottom      Left
       StageAlign.BOTTOM_RIGHT     Bottom      Right     
       
    flash.system.Capabilities的hasAudio和hasMP3屬性可以判斷flash player所在設備的音頻能力。
    stage.showDefaultContextMenu屬性設為false,可以隱藏掉一些系統默認菜單。
    posted @ 2007-01-13 15:42 The Matrix 閱讀(688) | 評論 (0)編輯 收藏

    事件是實現對象通訊的一個重要手段,對于構建一個靈活的系統來說是非常必要的。在Flash Player 9中,將事件發送機制內建在了flash.events.EventDispatcher類中。所有需要發送事件的類都必須繼承EventDispatcher類。
    調用EventDispatcher類中的addEventListener( ) and removeEventListener( )方法,就可以注冊或者移除事件監聽器。EventDispatcher中還定義了dispatchEvent()方法,可以使用該方法發送事件。dispatchEvent()方法至少需要一個參數,即flash.events.Event對象或者它的子類。

    原文如下:
    Events are an important way for objects to communicate. They are essential for creating flexible systems. Flash Player 9, for example, has a built-in event dispatching mechanism in the flash.events.EventDispatcher class. All classes that dispatch events inherit from EventDispatcher (e.g., NetStream and Sprite). If you want to define a class that dispatches events, you can extend EventDispatcher, as follows:

    package {
        import flash.events.EventDispatcher;
        public class Example extends EventDispatcher {

        }
    }


    The EventDispatcher class has public methods called addEventListener( ) and removeEventListener( ) that you can call from any instance of an EventDispatcher subclass to register event listeners. EventDispatcher also defines a protected method called dispatchEvent( ), which you can call from within a subclass to dispatch an event. The dispatchEvent( ) method requires at least one parameter as a flash.events.Event object or a subclass of Event.

    posted @ 2007-01-13 15:09 The Matrix 閱讀(463) | 評論 (0)編輯 收藏
    Another option is to use implicit getters and setters. Implicit getters and setters are declared as methods, but they look like properties. The syntax for a getter is as follows:

    public function get name(  ):Datatype {
    }

    The syntax for a setter is as follows:

    public function set name(value:Datatype):void {
    }

    這樣在代碼中調用counter.count=5時相當于調用了set count(5)方法。

    Counter類如下:
    public class Counter {
        private var _count:uint;
        public function Counter(  ) {
            _count = 0;
        }
        public function get count(  ):uint {
            return _count;
        }
        public function set count(value:uint):void {
            if(value < 100) {
                _count = value;
            }
            else {
                throw Error(  );
            }
        }
    }
    posted @ 2007-01-13 14:53 The Matrix 閱讀(572) | 評論 (0)編輯 收藏
    今天在網上看到這么一段,很實用:

    如果想要仔細看Hibernate生成的SQL語句,將format_sql設為true可以很大程度地減輕痛苦……
    hibernate.format_sql = true
    再加上這個的話:
    hibernate.use_sql_comments = true
    [可讀性 + 可定位性]會更好
    不過,這兩個一起來的話也會造成SQL在console中顯示的篇幅很大。
    posted @ 2006-11-24 22:24 The Matrix 閱讀(8046) | 評論 (1)編輯 收藏
    剛用Open Laszlo做了幾個項目,受夠了其無法調試,只能通過Debug將調試信息打印出來再慢慢研究錯在哪里,受夠了!
    試用了Flex2 Builder,備受其可以Debug的鼓舞,同時也受到了其Chart組件的誘惑,覺得這是一個比較有前途的RIA發展方向,決定研究一番。
    posted @ 2006-10-30 22:50 The Matrix 閱讀(475) | 評論 (0)編輯 收藏
    僅列出標題
    共4頁: 上一頁 1 2 3 4 
    主站蜘蛛池模板: 国产大片免费网站不卡美女 | 亚洲黄色在线视频| 亚洲欧洲自拍拍偷综合| 亚洲欧美日韩久久精品| j8又粗又长又硬又爽免费视频| 性xxxxx大片免费视频| 国产成人免费高清激情视频| 全部免费毛片在线| 亚洲av无码专区在线播放| 亚洲宅男精品一区在线观看| 精品视频免费在线| 久久久久久一品道精品免费看| 野花高清在线观看免费3中文 | 国产偷v国产偷v亚洲高清| 久久亚洲国产精品成人AV秋霞 | 五月天国产成人AV免费观看| 久久午夜夜伦鲁鲁片免费无码| 国产卡一卡二卡三免费入口| 亚洲国产综合无码一区二区二三区| 亚洲av无码一区二区三区乱子伦 | 亚洲第一男人天堂| 国产免费一区二区三区免费视频 | 久久亚洲国产精品成人AV秋霞| 九九精品国产亚洲AV日韩| 日本免费中文视频| 免费看片免费播放| 久久青青草原亚洲AV无码麻豆| 亚洲高清乱码午夜电影网| 日本高清高色视频免费| 国产18禁黄网站免费观看| 91精品国产亚洲爽啪在线观看| 美女尿口扒开图片免费| 88av免费观看入口在线| 免费在线视频一区| 亚洲国产一区在线观看| 久久久久久av无码免费看大片| 国产成人免费网站| 亚洲国产精品成人久久| 国产成人精品久久亚洲高清不卡| 日韩视频在线观看免费| 亚洲国产成人爱av在线播放|