posts - 33,  comments - 70,  trackbacks - 0
          Compass也提供另一直配置, 使用java5 的annotation 來進行OSEM.
          下面就是簡單的Plain Old Java Object (POJO)類型的搜索類,使用了Compass annotations.在運行時刻, compass抽取對象屬性插入和相應源數據索引中.

          public?class?Product??{?????
          ????@SearchableId
          ????
          private?Integer?id;
          ????
          private?Category?category;
          ????
          private?Integer?inventory;
          ????
          private?String?name;
          ????
          private?String?descn;
          ????
          private?Double?unitprice;
          ????
          private?String?status;
          ????
          private?String?shortDescn?=?null;
          ????
          private?Date?createTime;
          ????
          private?Date?modifyTime;
          ????
          private?User?createUser;
          ????
          private?User?modifyUser;
          ????@SearchableProperty(name?
          =?"name")
          ????
          public?String?getName()?{
          ????????
          return?this.name;
          ????}

          ????@SearchableProperty(name?
          =?"descn")
          ????
          public?String?getDescn()?{
          ????????
          return?this.descn;
          ????}

          ????
          public?Double?getUnitprice()?{
          ????????
          return?this.unitprice;
          ????}

          ????
          public?void?setUnitprice(Double?unitprice)?{
          ????????
          this.unitprice?=?unitprice;
          ????}

          ????setter
          /getter

          @Searchable(alias?=?"book")
          public?class?Book?extends?Product?{
          ????
          private?String?image;
          ????
          private?String?author;
          ????
          private?String?publisher;
          ????
          private?String?publishDate;
          ????
          public?Book()?{}
          ????
          public?String?getImage()?{
          ??????
          return?image;
          ????}

          ????
          public?void?setImage(String?image)?{
          ??????
          this.image?=?image;
          ????}

          ????@SearchableProperty(name?
          =?"author")
          ????
          public?String?getAuthor()?{
          ??????
          return?author;
          ????}

          ????
          public?void?setAuthor(String?author)?{
          ??????
          this.author?=?author;
          ????}

          ????@SearchableProperty(name?
          =?"publisher")
          ????
          public?String?getPublisher()?{
          ??????
          return?publisher;
          ????}

          ????
          public?void?setPublisher(String?publisher)?{
          ??????
          this.publisher?=?publisher;
          ????}

          ????
          public?String?getPublishDate()?{
          ??????
          return?publishDate;
          ????}

          ????
          public?void?setPublishDate(String?publishDate)?{
          ??????
          this.publishDate?=?publishDate;
          ????}

          }

          注意: 對象必須遵守下面的規則.
          1. 所有的持久化類必須有默認構造函數(沒參數構造方法).
          2. OSEM要求映射類JavaBean必須有一個或更多的id主建. id屬性可以是對象類型,例如java.lang.String or java.util.Date.
          ??并且類注解使用@SearchableClassConverter或者使用定義Converter(通常繼承Compass AbstractBasicConverter).
          3. 使用JavaBean規范, getter/setter.

          更多:@Searchable,@SearchableId,@SearchableProperty and So On Look: http://www.opensymphony.com/compass/content/documentation.html

          posted on 2006-06-04 22:44 地獄男爵(hellboys) 閱讀(2580) 評論(3)  編輯  收藏 所屬分類: 編程語言(c/c++ java python sql ......)

          FeedBack:
          # re: compass 中使用annatation 簡化配置
          2006-06-16 09:54 | 上帝使者
          確實簡單不少啊。現在對annatation有點改觀了,呵呵。

          期待對高亮搜索和html檢索的文章,哈哈  回復  更多評論
            
          # re: compass 中使用annatation 簡化配置
          2006-12-13 14:33 | joseph
          你好
          你有msn和qq嗎我現在也在學compass 我怎么樣吧 spring mvc架構改造成webwork呀  回復  更多評論
            
          # re: compass 中使用annatation 簡化配置
          2008-11-20 10:13 | 老丁
          遇到 clob和blob字段報錯:
          Exception in thread "main" org.compass.core.mapping.MappingException: No converter defined for type [java.sql.Clob]

          要怎么解決呀?  回復  更多評論
            
          <2006年6月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          常用鏈接

          隨筆分類

          隨筆檔案

          文章檔案

          相冊

          連接

          最新隨筆

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 遂昌县| 华亭县| 新郑市| 黑龙江省| 剑川县| 金坛市| 长沙市| 松潘县| 和平县| 五指山市| 东明县| 陈巴尔虎旗| 龙陵县| 南通市| 临潭县| 三亚市| 潮安县| 吉木乃县| 连平县| 平安县| 漠河县| 咸丰县| 海兴县| 克东县| 始兴县| 翁牛特旗| 上林县| 宝坻区| 蓬溪县| 大足县| 皋兰县| 禄劝| 景宁| 隆德县| 深水埗区| 游戏| 晋州市| 榕江县| 安丘市| 图片| 东港市|