Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8713445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:20:50+00:00 2026-06-13T05:20:50+00:00

I cannot read timestamp data from QueryResponse (want to cast result to a POJO).

  • 0

I cannot read timestamp data from QueryResponse (want to cast result to a POJO). If Im using SolrDocumentList there are no errors.

db-data-config.xml:

<entity name="discussion" dataSource="mssqlDatasource" pk="id"
        transformer="TemplateTransformer, DateFormatTransformer"
        query="SELECT d.id, d.title, d.created,
               u.first_name, u.last_name,
               db.type AS boardType, db.country
               FROM discussion d
               INNER JOIN wtb_user u ON d.author = u.id
               INNER JOIN discussion_category dc ON d.category = dc.id
               INNER JOIN discussion_board db ON dc.board = db.id">                   
        <!--<field column="created" dateTimeFormat='yyyyMMdd HH:mm:ss z' />-->
        <!--<field column="created" dateTimeFormat='yyyyMMdd' />-->
        <field column="first_name" name="firstName" />
        <field column="last_name" name="lastName" />
        <field column="tableType" template="DISCUSSION" />

        <entity name="discussion_post" dataSource="mssqlDatasource"
            transformer="ClobTransformer"
            query="SELECT dp.message
                   FROM discussion_post dp
                   WHERE dp.discussion = '${discussion.id}'">
            <field column="message" name="discussionPostMessage" clob="true" />
        </entity>
    </entity>

schema.xml:

<field name="created" type="date" indexed="false" stored="true"/> 

the field ‘created’ is a timestamp in my database and after inserting index data a result looks like (called with browser admin console) :

  <result name="response" numFound="246" start="0">
  <doc>
   <str name="boardType">1</str>
   <date name="created">2012-10-05T07:29:23.387Z</date>
   <arr name="discussionPostMessage">
    <str>message test</str>
    <str>second</str>
    <str>third</str>
   </arr>
   <str name="firstName">Ashley</str>
   <str name="id">10</str>
   <str name="lastName">Morgan</str>
   <str name="tableType">DISCUSSION</str>
   <str name="title">headline test</str>
  </doc>
  ...

Now I tried to to query a ‘all result’

public void search(String searchString) {
    SolrQuery query = new SolrQuery();
    QueryResponse rsp;
    try {
        query = new SolrQuery();
        query.setQuery(DEFAULT_QUERY);
        query.setRows(246);

        rsp = getServer().query(query);

        SolrDocumentList solrDocumentList = rsp.getResults(); // IllegalArgumentException
        List<SearchRequestResponseObject> beans = rsp.getBeans(SearchRequestResponseObject.class); //works
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

SearchRequestResponseObject.class:

public class SearchRequestResponseObject {
@Field
private String id;

@Field
private String title;

@Field
@Temporal(TemporalType.TIMESTAMP)
    //@DateTimeFormat(style = "yyyyMMdd HH:mm:ss z")
//@DateTimeFormat(style = "yyyyMMdd")
private Timestamp created;
    ...
}

Exception:

Caused by: java.lang.IllegalArgumentException: Can not set java.sql.Timestamp field com.solr.SearchRequestResponseObject.created to java.util.Date
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:374)
... 45 more

Detail Message:

Exception while setting value : Fri Oct 05 09:29:23 CEST 2012 on private java.sql.Timestamp com.solr.SearchRequestResponseObject.created

What do Im wrong? Why should be ‘created’ a Date?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:20:51+00:00Added an answer on June 13, 2026 at 5:20 am

    Your ‘created’ field should be a date because even though you are passing in a TimeStamp from your database, it is being stored internally as a Date in Solr and is therefore being exposed as a Date from Solr. SolrJ does not understand how to handle a TimeStamp. If you really want to have TimeStamp property on your POJO, you will need to get the field from Solr as a Date and then have a separate TimeStamp property on your POJO that converts the Date value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A client wants to ensure that I cannot read sensitive data from their site,
On the query below I keep getting this error: Cannot read the next data
I want to read two matrices from two different txt files, and say output
I'm getting the following error: TypeError: Cannot read property 0.0 from null. (line227) I've
I am getting TypeError: Cannot read property parameter from undefined. when trying to log
It means I cannot read the trace from all instance directly?
I have this error: Uncaught TypeError: Cannot read property 'Geocoder' of undefined From this
I've read that you cannot read the HTML of another frame if that frame
I'm getting the error: Uncaught TypeError: Cannot read property 'constructor' of undefined When declaring
I'm getting an an error TypeError: Cannot read property 'style' of undefined I'd be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.