资源描述:
《Compass整合SSH》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Compass整合SSH(2010-11-2317:39:00)标签:compasssshj2eeit分类:数据编程经过三天的折腾,终于把Compass整合SSH搞定了,下边贴出源码,给正在学习的朋友,毕竟网上关于Compass的详细介绍还是太少了。我用到的版本是struts2+spring2.5+hibernate3.2+compass2.2+Quartz1.6一、创建一张表,表名PRODUCTCREATETABLE"LICE"."PRODUCT"("PRODUCT_ID"VARCHAR2(40)NOTNULLENABLE,"PRODUCT_NAME"
2、VARCHAR2(80),"PRODUCT_PRICE"NUMBER(6,2),"PRODUCT_BRAND"VARCHAR2(40),"PRODUCT_DESC"VARCHAR2(200),"VERSION"NUMBER(10,0),PRIMARYKEY("PRODUCT_ID"))二、PRODUCT表对应的实体类packagecom.lice.model;importjavax.persistence.Column;importjavax.persistence.Entity;importjavax.persistence.GeneratedValu
3、e;importjavax.persistence.Id;importjavax.persistence.Table;importjavax.persistence.Version;importorg.hibernate.annotations.GenericGenerator;importorg.compass.annotations.*;@Entity@Table(name="PRODUCT",schema="LICE")@SearchablepublicclassProductimplementsjava.io.Serializable{//Fie
4、lds@SearchableIdprivateStringproductId;@SearchableProperty(name="productName")privateStringproductName;@SearchableProperty(name="productPrice")privateDoubleproductPrice;@SearchableProperty(name="productBrand")privateStringproductBrand;@SearchableProperty(name="productDesc")privat
5、eStringproductDesc;@SearchableProperty(name="version")privateIntegerversion;//ConstructorspublicProduct(){}publicProduct(StringproductName,DoubleproductPrice,StringproductBrand,StringproductDesc){this.productName=productName;this.productPrice=productPrice;this.productBrand=produc
6、tBrand;this.productDesc=productDesc;}//Propertyaccessors@GenericGenerator(name="generator",strategy="uuid.hex")@Id@GeneratedValue(generator="generator")@Column(name="PRODUCT_ID",unique=true,nullable=false,length=40)publicStringgetProductId(){returnthis.productId;}publicvoidsetPro
7、ductId(StringproductId){this.productId=productId;}@Column(name="PRODUCT_NAME",length=80)publicStringgetProductName(){returnthis.productName;}publicvoidsetProductName(StringproductName){this.productName=productName;}@Column(name="PRODUCT_PRICE",precision=6)publicDoublegetProductPr
8、ice(){returnthis.productPrice;}publicvoi