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

          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;
          ????}

          }

          注意: 對象必須遵守下面的規(guī)則.
          1. 所有的持久化類必須有默認(rèn)構(gòu)造函數(shù)(沒參數(shù)構(gòu)造方法).
          2. OSEM要求映射類JavaBean必須有一個或更多的id主建. id屬性可以是對象類型,例如java.lang.String or java.util.Date.
          ??并且類注解使用@SearchableClassConverter或者使用定義Converter(通常繼承Compass AbstractBasicConverter).
          3. 使用JavaBean規(guī)范, 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) 閱讀(2583) 評論(3)  編輯  收藏 所屬分類: 編程語言(c/c++ java python sql ......)

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

          期待對高亮搜索和html檢索的文章,哈哈  回復(fù)  更多評論
            
          # re: compass 中使用annatation 簡化配置
          2006-12-13 14:33 | joseph
          你好
          你有msn和qq嗎我現(xiàn)在也在學(xué)compass 我怎么樣吧 spring mvc架構(gòu)改造成webwork呀  回復(fù)  更多評論
            
          # 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]

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

          常用鏈接

          隨筆分類

          隨筆檔案

          文章檔案

          相冊

          連接

          最新隨筆

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 神池县| 新闻| 北票市| 武宁县| 新干县| 奉贤区| 衡东县| 邢台县| 嘉定区| 庆安县| 当涂县| 两当县| 阿城市| 宁蒗| 开封县| 简阳市| 县级市| 丰城市| 喀喇沁旗| 宁化县| 闵行区| 永昌县| 广南县| 孟津县| 西贡区| 楚雄市| 滨州市| 湖州市| 紫云| 台前县| 扎兰屯市| 图片| 昌都县| 蛟河市| 永平县| 辽宁省| 恩平市| 泾源县| 康平县| 武穴市| 泰安市|