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

          常用鏈接

          隨筆分類

          隨筆檔案

          文章檔案

          相冊

          連接

          最新隨筆

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 隆尧县| 冀州市| 永修县| 南安市| 错那县| 凉城县| 龙口市| 武鸣县| 田阳县| 枝江市| 封丘县| 成安县| 容城县| 当雄县| 东阿县| 黄骅市| 开阳县| 体育| 清远市| 板桥市| 东山县| 合阳县| 武川县| 汉川市| 柯坪县| 浮山县| 林口县| 顺昌县| 安阳县| 大冶市| 蓬安县| 陆川县| 遵义市| 集安市| 晋中市| 沙田区| 西昌市| 安福县| 康保县| 萨嘎县| 光泽县|