[infinispan-issues] [JBoss JIRA] (ISPN-1820) SearchMapping is not recognized

Michael Wittig (JIRA) jira-events at lists.jboss.org
Tue Jan 31 09:08:49 EST 2012


     [ https://issues.jboss.org/browse/ISPN-1820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Wittig updated ISPN-1820:
---------------------------------

    Steps to Reproduce: See attached test cases  (was: /**
	 * Here we use SearchMapping to have the ability to add Objects to the cache where Annotations are not possible.
	 */
	@Test
	public void testSearchMapping() {
        final SearchMapping mapping = new SearchMapping();
        mapping
        	.entity(BondPVO.class)
        		.indexed()
        		.providedId()
        			.property("id", ElementType.METHOD)
        			.property("name", ElementType.METHOD)
        			.property("isin", ElementType.METHOD)
        ;
        
        final Properties properties = new Properties();
        properties.put("hibernate.search.default.directory_provider", "ram");
        properties.put(Environment.MODEL_MAPPING, mapping);
        
        final Configuration config = new ConfigurationBuilder()
        	.indexing()
        		.enable()
        		.indexLocalOnly(true)
        	.withProperties(properties)
        .build();
        
        final DefaultCacheManager cacheManager = new DefaultCacheManager(config);
        final Cache<Long, BondPVO> cache = cacheManager.getCache();
        final SearchManager sm = Search.getSearchManager(cache);
        
        final BondPVO bond = new BondPVO(1, "Test", "DE000123");
        try {
        	cache.put(bond.getId(), bond);
        } catch (final SearchException e) {
        	fail("SearchMapping not working: " + e.getMessage());
        }
        
        final QueryBuilder qb = sm.buildQueryBuilderForClass(BondPVO.class).get();
        final Query q = qb.keyword().onField("name").matching("Test").createQuery();
        final CacheQuery cq = sm.getQuery(q, BondPVO.class);
        assertEquals(1, cq.getResultSize());
    }
    
    public static final class BondPVO {

		private long id;
		
		private String name;
		
		private String isin;

		public BondPVO(long id, String name, String isin) {
			super();
			this.id = id;
			this.name = name;
			this.isin = isin;
		}

		public long getId() {
			return id;
		}

		public void setId(long id) {
			this.id = id;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getIsin() {
			return isin;
		}

		public void setIsin(String isin) {
			this.isin = isin;
		}
	}
    
    /**
	 * Here we show that the first test could work.
	 */
    @Test
	public void testWithoutSearchMapping() {

        final Properties properties = new Properties();
        properties.put("hibernate.search.default.directory_provider", "ram");
        
        final Configuration config = new ConfigurationBuilder()
        	.indexing()
        		.enable()
        		.indexLocalOnly(true)
        	.withProperties(properties)
        .build();
        
        final DefaultCacheManager cacheManager = new DefaultCacheManager(config);
        final Cache<Long, BondPVO2> cache = cacheManager.getCache();
        final SearchManager sm = Search.getSearchManager(cache);
        
        final BondPVO2 bond = new BondPVO2(1, "Test", "DE000123");
        cache.put(bond.getId(), bond);
        final QueryBuilder qb = sm.buildQueryBuilderForClass(BondPVO2.class).get();
        final Query q = qb.keyword().onField("name").matching("Test").createQuery();
        final CacheQuery cq = sm.getQuery(q, BondPVO2.class);
        assertEquals(1, cq.getResultSize());
    }
   
    @Indexed @ProvidedId
    public static final class BondPVO2 {

    	@Field
		private long id;
		
    	@Field
		private String name;
		
    	@Field
		private String isin;

		public BondPVO2(long id, String name, String isin) {
			super();
			this.id = id;
			this.name = name;
			this.isin = isin;
		}

		public long getId() {
			return id;
		}

		public void setId(long id) {
			this.id = id;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getIsin() {
			return isin;
		}

		public void setIsin(String isin) {
			this.isin = isin;
		}
	})
       Forum Reference: https://community.jboss.org/message/648612#648612  (was: https://community.jboss.org/message/648612#648612)

    
> SearchMapping is not recognized
> -------------------------------
>
>                 Key: ISPN-1820
>                 URL: https://issues.jboss.org/browse/ISPN-1820
>             Project: Infinispan
>          Issue Type: Bug
>          Components: Querying
>    Affects Versions: 5.1.0.FINAL
>         Environment: Windows XP, Java 1.6.0_26
>            Reporter: Michael Wittig
>            Assignee: Sanne Grinovero
>              Labels: annotation, query,, searchmapping
>         Attachments: ISPN1820Test.java
>
>
> SearchMapping is not recognized by Infinispan and therfore it is not possible to add Objects to cache where you can not add Annotations. (maybe you just have the class Files)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the infinispan-issues mailing list