1 Reply Latest reply on Feb 4, 2013 1:46 AM by Nicklas Karlsson

    Jboss thrown exception on SpatialFieldBridge?

    Sam W Expert

      Hi

       

      With hibernate search 4.2.1 Final and jboss 7.1.1.Final, when I execute the search function, jboss thrown the following exception:

       

       

      23:13:17,748 DEBUG [org.hibernate.engine.transaction.spi.AbstractTransactionImpl] (Hibernate Search: collectionsloader-2) committing

      23:13:17,749 DEBUG [org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer] (Hibernate Search: collectionsloader-2) finished

      23:13:17,749 DEBUG [org.hibernate.search.batchindexing.impl.BatchIndexingWorkspace] (Hibernate Search: BatchIndexingWorkspace-1) All work for type ForestSurf.entity.MyisamProductArticle has been produced

      23:13:17,749 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (Hibernate Search: collectionsloader-2) Aggressively releasing JDBC connection

      23:13:17,798 DEBUG [org.hibernate.search.backend.impl.lucene.works.FlushWorkDelegate] (http--192.168.1.20-8080-7) performing FlushWorkDelegate

      23:13:17,804 INFO  [org.hibernate.search.impl.SimpleIndexingProgressMonitor] (http--192.168.1.20-8080-7) HSEARCH000028: Reindexed 1 entities

      23:13:17,811 DEBUG [ForestSurf.entity.facade.MyisamProductArticleFacade] (http--192.168.1.20-8080-7) =====else: termsStr: mattress; lat: -33.794883; lon: 151.268071; radius: 100.0

      23:13:17,824 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (http--192.168.1.20-8080-7) Aggressively releasing JDBC connection

      23:13:17,825 DEBUG [org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl] (http--192.168.1.20-8080-7) Skipping JTA sync registration due to auto join checking

      23:13:17,825 ERROR [org.jboss.ejb3.invocation] (http--192.168.1.20-8080-7) JBAS014134: EJB Invocation failed on component MyisamProductArticleFacade for method public abstract java.util.List ForestSurf.entity.facade.MyisamProductArticleFacadeLocal.search(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Double,java.lang.Double,java.lang.Double,java.lang.Integer,java.lang.Integer): javax.ejb.EJBException: org.hibernate.search.SearchException: HSEARCH000131: The field used for the spatial query is not using SpatialFieldBridge: ForestSurf.entity.MyisamProductArticle._hibernate_default_coordinates

              at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]

       

       

      Here is my entity class:

       

       

      @Entity

      @Table(name = "myisam_product_article", catalog = "forestsurf", schema = "")

      @XmlRootElement

      @NamedQueries({

          @NamedQuery(name = "MyisamProductArticle.findAll", query = "SELECT m FROM MyisamProductArticle m"),

          @NamedQuery(name = "MyisamProductArticle.findByArticleId", query = "SELECT m FROM MyisamProductArticle m WHERE m.articleId = :articleId"),

          @NamedQuery(name = "MyisamProductArticle.findByProductId", query = "SELECT m FROM MyisamProductArticle m WHERE m.productId = :productId"),

          @NamedQuery(name = "MyisamProductArticle.findByHeader", query = "SELECT m FROM MyisamProductArticle m WHERE m.header = :header")})

       

       

      //@Spatial(spatialMode = SpatialMode.GRID, name="location")

      @Spatial(name="location")

      //This annotation tells hibernate search that this class has to be indexed

      @Indexed(index = "MyisamProductArticle")

      @Analyzer(impl = org.apache.lucene.analysis.standard.StandardAnalyzer.class)

      @AnalyzerDef(name = "customanalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),

              filters = {@TokenFilterDef(factory = LowerCaseFilterFactory.class),

                          @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {

                              @Parameter(name = "language", value = "English"),

                          }),

                          @TokenFilterDef(factory = SynonymFilterFactory.class, params = {

                              @Parameter(name = "ignoreCase", value = "true"),

                              @Parameter(name = "expand", value = "true"),

                              @Parameter(name = "synonyms", value="synonyms.txt")}),

          })

      public class MyisamProductArticle implements Serializable, Coordinates, Comparable<MyisamProductArticle> {

          private static final long serialVersionUID = 1L;

          @Id

          @Basic(optional = false)

          @NotNull

          @Column(name = "article_id")

          private Integer articleId;

          @Basic(optional = false)

          @NotNull

          @Column(name = "product_id")

          private int productId;

          @Lob

          @Size(max = 65535)

          @Column(name = "a_desc")

          @Analyzer(definition = "customanalyzer")

      @Field(index = Index.YES, store = Store.YES)

          private String aDesc;

          @Size(max = 255)

          @Column(name = "header")

      @Field(index = Index.YES, store = Store.YES)

          @Analyzer(definition = "customanalyzer")

          private String header;

          @Size(max = 64)

          @Column(name = "parent_category_name")

          @Analyzer(definition = "customanalyzer")

          @Field(index = Index.YES, store = Store.YES)

          private String parentCategoryName;

          @Size(max = 64)

          @Column(name = "sub_category_name")

          @Analyzer(definition = "customanalyzer")

          @Field(index = Index.YES, store = Store.YES)

          private String subCategoryName;

          @Size(max = 5)

          @Column(name = "postcode")

          @Analyzer(definition = "customanalyzer")

          @Field(index = Index.YES, store = Store.YES)

          private String postcode;

         

          @Size(max = 50)

          @Column(name = "state")

          @Analyzer(definition = "customanalyzer")

          @Field(index = Index.YES, store = Store.YES)

          private String state;

      //    @Size(max = 50)

          @Column(name = "latitude")

      //    @Latitude(of="location")

          private Double latitude;

      //    @Size(max = 50)

          @Column(name = "longitude")

      //    @Longitude(of="location")

          private Double longitude;

          @Column(name = "creation_date")

          @Temporal(TemporalType.DATE)

          @Boost(2.0f)

          @Field(index = Index.YES, store = Store.YES)

          @DateBridge(resolution=Resolution.DAY)

          private Date creationDate;

         

         

          public MyisamProductArticle() {

          }

       

       

          public MyisamProductArticle(Integer articleId) {

              this.articleId = articleId;

          }

       

       

          public MyisamProductArticle(Integer articleId, int productId) {

              this.articleId = articleId;

              this.productId = productId;

          }

       

       

          public Integer getArticleId() {

              return articleId;

          }

       

       

          public void setArticleId(Integer articleId) {

              this.articleId = articleId;

          }

       

       

          public int getProductId() {

              return productId;

          }

       

       

          public void setProductId(int productId) {

              this.productId = productId;

          }

       

       

          public String getADesc() {

              return aDesc;

          }

       

       

          public void setADesc(String aDesc) {

              this.aDesc = aDesc;

          }

       

       

          public String getHeader() {

              return header;

          }

       

       

          public void setHeader(String header) {

              this.header = header;

          }

       

       

          public String getParentCategoryName() {

              return parentCategoryName;

          }

       

       

          public void setParentCategoryName(String parentCategoryName) {

              this.parentCategoryName = parentCategoryName;

          }

       

       

          public String getSubCategoryName() {

              return subCategoryName;

          }

       

       

          public void setSubCategoryName(String subCategoryName) {

              this.subCategoryName = subCategoryName;

          }

       

       

          public String getPostcode() {

              return postcode;

          }

          public String getState() {

              return state;

          }

       

       

          public void setState(String state) {

              this.state = state;

          }

       

       

         

          public void setPostcode(String postcode) {

              this.postcode = postcode;

          }

       

       

          @Override

          public Double getLatitude() {

              return latitude;

          }

       

       

          public void setLatitude(Double lat) {

              this.latitude = lat;

          }

       

       

          @Override

          public Double getLongitude() {

              return longitude;

          }

      public void setLongitude(Double lon) {

              this.longitude = lon;

          }

       

       

          public Date getCreationDate() {

              return creationDate;

          }

       

       

          public void setCreationDate(Date creationDate) {

              this.creationDate = creationDate;

          }

       

       

       

       

      Search function:

       

      .must(qb.spatial()

                                      .onCoordinates( "location" )

                                      .within( radius, Unit.KM )

                                      .ofLatitude( lat )

                                      .andLongitude( lon ).createQuery()

       

       

       

      Any suggestion is very much appreciated.

      Thanks

      Samuel