lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noble Paul നോബിള്‍ नोब्ळ् <noble.p...@corp.aol.com>
Subject Re: Type converters for DocumentObjectBinder
Date Fri, 13 Nov 2009 07:02:56 GMT
create a setter method for the field which take s a Stringand apply
the annotation there

example


private Calendar validFrom;

@Field
public void setvalidFrom(String s){
    //convert to Calendar object and set the field
}


On Fri, Nov 13, 2009 at 12:24 PM, paulhyo <steph@ouestil.ch> wrote:
>
> Hi,
>
> I would like to know if there is a way to add type converters when using
> getBeans. I need convertion when Updating (Calendar -> String) and when
> Searching (String -> Calendar)
>
>
> The Bean class defines :
> @Field
> private Calendar validFrom;
>
> but the recieved type within Query Response is a String (2009-11-13)...
>
> Actually I get this error :
>
> java.lang.RuntimeException: Exception while setting value : 2009-09-16 on
> private java.util.Calendar
> ch.mycompany.access.solr.impl.SoNatPersonImpl.validFrom
>        at
> org.apache.solr.client.solrj.beans.DocumentObjectBinder$DocField.set(DocumentObjectBinder.java:360)
>        at
> org.apache.solr.client.solrj.beans.DocumentObjectBinder$DocField.inject(DocumentObjectBinder.java:342)
>        at
> org.apache.solr.client.solrj.beans.DocumentObjectBinder.getBeans(DocumentObjectBinder.java:55)
>        at
> org.apache.solr.client.solrj.response.QueryResponse.getBeans(QueryResponse.java:324)
>        at
> ch.mycompany.access.solr.impl.result.NatPersonPartnerResultBuilder.buildBeanListResult(NatPersonPartnerResultBuilder.java:38)
>        at
> ch.mycompany.access.solr.impl.SoQueryManagerImpl.searchNatPersons(SoQueryManagerImpl.java:41)
>        at
> ch.mycompany.access.solr.impl.SolrQueryManagerTest.testQueryFamilyNameRigg(SolrQueryManagerTest.java:36)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at junit.framework.TestCase.runTest(TestCase.java:164)
>        at junit.framework.TestCase.runBare(TestCase.java:130)
>        at junit.framework.TestResult$1.protect(TestResult.java:106)
>        at junit.framework.TestResult.runProtected(TestResult.java:124)
>        at junit.framework.TestResult.run(TestResult.java:109)
>        at junit.framework.TestCase.run(TestCase.java:120)
>        at junit.framework.TestSuite.runTest(TestSuite.java:230)
>        at junit.framework.TestSuite.run(TestSuite.java:225)
>        at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
>        at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: java.lang.IllegalArgumentException: Can not set
> java.util.Calendar field
> ch.mycompany.access.solr.impl.SoNatPersonImpl.validFrom to java.lang.String
>        at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
>        at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
>        at
> sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
>        at java.lang.reflect.Field.set(Field.java:657)
>        at
> org.apache.solr.client.solrj.beans.DocumentObjectBinder$DocField.set(DocumentObjectBinder.java:354)
>        ... 24 more
>
> Thank you in advance
>
> Paulhyo
>
> --
> View this message in context: http://old.nabble.com/Type-converters-for-DocumentObjectBinder-tp26332174p26332174.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
-----------------------------------------------------
Noble Paul | Principal Engineer| AOL | http://aol.com

Mime
View raw message