Spring JDBC BeanPropertyRowMapper yes no ('Y','N') to boolean bean properties - database

I have a class with some string, int and boolean fields. I have the getters and setters declared for them.
public class SomeClass {
private int id;
private String description;
private boolean active;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
}
I am BeanPropertyRowMapper to get all the objects from and Oracle DB.
#Override
public List<Destination> getAll() {
List<SomeClass> objs = jdbcTemplate.query(
myQuery, new BeanPropertyRowMapper<SomeClass>(SomeClass.class));
return objs;
}
If the debug is turned on I see:
[3/14/13 10:02:09:202 EDT] 00000018 SystemOut O DEBUG BeanPropertyRowMapper - Mapping column 'ID' to property 'id' of type int
[3/14/13 10:02:09:202 EDT] 00000018 SystemOut O DEBUG BeanPropertyRowMapper - Mapping column 'DESCRIPTION' to property 'description' of type class java.lang.String
And then it fails trying to map active. Active is defined as 1 byte CHAR in the DB with values as 'Y' or 'N'. What is the best way to use BeanPropertyRowMapper and successfully convert values such as 'Y', and 'N' to boolean?

So I figured out how to do this. I extended BeanPropertyRowMapper and handler boolean types through some custom code before handing off the control to beanpropertyrowmapper for rest of the data types.
Note: It works for me because I use oracle and all of the 'boolean' type columns are strings with 'y','yes','n' & 'no' type values.
Those who use numerical 1,0 or other formats could potentially improve it further by making it generic through an object yes map and getting objects from resultset and looking them up in this map. Hope this helps someone else in a situation like mine.
import java.beans.PropertyDescriptor;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
/**
* Extends BeanPropertyRowMapper to allow for boolean fields
* mapped to 'Y,'N' type column to get set correctly. Using stock BeanPropertyRowMapper
* would throw a SQLException.
*
*/
public class ExtendedBeanPropertyRowMapper<T> extends BeanPropertyRowMapper<T> {
//Contains valid true values
public static final Set<String> TRUE_SET = new HashSet<String>(Arrays.asList("y", "yes", "true"));
public ExtendedBeanPropertyRowMapper(Class<T> class1) {
super(class1);
}
#Override
/**
* Override <code>getColumnValue</code> to add ability to map 'Y','N' type columns to
* boolean properties.
*
* #param rs is the ResultSet holding the data
* #param index is the column index
* #param pd the bean property that each result object is expected to match
* (or <code>null</code> if none specified)
* #return the Object value
* #throws SQLException in case of extraction failure
* #see org.springframework.jdbc.core.BeanPropertyRowMapper#getColumnValue(java.sql.ResultSet, int, PropertyDescriptor)
*/
protected Object getColumnValue(ResultSet rs, int index,
PropertyDescriptor pd) throws SQLException {
Class<?> requiredType = pd.getPropertyType();
if (boolean.class.equals(requiredType) || Boolean.class.equals(requiredType)) {
String stringValue = rs.getString(index);
if(!StringUtils.isEmpty(stringValue) && TRUE_SET.contains(stringValue.toLowerCase())){
return true;
}
else return false;
}
return super.getColumnValue(rs, index, pd);
}
}

BeanPropertyRowMapper will convert values into a Boolean object with 0=false and 1=true. Just tried this and it works.
This blog post has more information, as well as code examples in Java and C with OCCI.

Old question, but you can do something like
public void setIsActive(String active) {
this.active = "Y".equalsIgnoreCase(active);
}

As pointed out by Harikumar, BeanPropertyRowMapper does in fact convert 0 and 1 to boolean values. I couldn't find any documentation to support this, but this is in fact the current case.
So, a solution that doesn't require you to extend BeanPropertyRowMapper would be to decode your column into these values:
#Override
public List<Destination> getAll() {
List<SomeClass> objs = jdbcTemplate.query(
"SELECT ID, DESCRIPTION, " +
" DECODE(ACTIVE, 'Y', 1,'N', 0) as ACTIVE " +
" FROM YOUR_TABLE",
new BeanPropertyRowMapper<SomeClass>(SomeClass.class));
return objs;
}

Related

Serializing childdocuments, fields spring data solr

I am trying to persist nested documents in solr. I have tried both Field(child= true) and #Childdocument annotation.
With #Field(child=true) & #ChildDocument i get
[doc=null] missing required field: id, retry=0 commError=false
errorCode=400
I tried #Indexed with #Id. Also tried to specify required = false.
#Service
public class NavigationMapper implements DocumentMapper<Navigation> {
#Override
public SchemaDefinition getSchemaDefinition() {
SchemaDefinition sd = new SchemaDefinition();
sd.setName(Navigation.class.getSimpleName());
sd.setFields(new ArrayList<>());
for(Method method : Navigation.class.getDeclaredMethods()){
if(method.getName().startsWith("get") && method.getParameterCount() <= 0){
SchemaDefinition.FieldDefinition fd = new SchemaDefinition.FieldDefinition();
String fieldName = method.getName().replace("get", "");
fd.setName(fieldName.replace(fieldName.charAt(0), fieldName.toLowerCase().charAt(0)));
fd.setRequired(false);
fd.setStored(true);
sd.getFields().add(fd);
}
}
return sd;
}
With #Field i get the package name in the stored value :
activePage:
["org.apache.solr.common.SolrInputField:activePage=Page(id=blt6134c9cf711a7c27,
and get below error while i try to read in my rest controller.
No converter found capable of converting from type [java.lang.String]
to type [com.blizzard.documentation.data.shared.model.page.Page]
I did a lot of reading about this and haven't been able to successfully configure and persist the nested document in SolrDb. I read that i could use SolrJConverter for this , but not sucessfull with it either. Is there any working example i can refer to or tutorial about this feature?
#Data
#SolrDocument(collection = "Navigation")
public class Navigation implements Serializable {
#Id
//#Indexed(required = false)
private String id;
#Field
#Indexed(name = "path", type = "string")
private String path;
#ChildDocument
private Page navigationRoot;
#ChildDocument
private Page activePage;
}
#Data
#SolrDocument(collection = "Page")
public class Page implements Serializable {
#Id
// #Indexed(name= "id", type="string", required = false)
private String id;
#Field
#Indexed(name= "path", type="string")
private String path;
#Field
private PageContentType contentType;
#ChildDocument
private List<Page> children;
#Indexed("root_b")
private boolean root;
}
I expect to store the nested document inthe solrDb.

Tableview update database on edit

So the thing that i want to happen, is making the tableview update the data in the database after editing it. I wanted to use the SetOnEditCommit method here. The cell editing does work, but it never gets updated, with no error either. In the first place im a bit clueless if this method is actually efficient (probably not), since its hard to find some sources for this specific thing. And the sources that i found weren't really helpful. So it would be nice if someone had an idea as to why it doesn't update, or maybe provide an alternate option here.
The mentioned part:
columnType.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<UserDetails, String>>() {
#Override
public void handle(TableColumn.CellEditEvent<UserDetails, String> event) {
updataData();
}
});
tableview.setItems(null);
tableview.setItems(data);
}
public void updataData() {
Connection connection = null;
try {
connection = DriverManager.getConnection("jdbc:mysql://37.128.148.113:3306/FYS", "FYS", "Kcj8g87~");
Statement con = connection.createStatement();
//connection
TablePosition pos = tableview.getSelectionModel().getSelectedCells().get(0);
int row = pos.getRow();
TableColumn col = pos.getTableColumn();
String data1 = (String) col.getCellObservableValue(row).getValue();
//cell
UserDetails row1 = tableview.getSelectionModel().getSelectedItem();
c1 = row1.getId();
//row
//tableview variables
con.execute("UPDATE gevonden_bagage SET type = 'data1' WHERE koffer_id = 'c1' ");
//Query
} catch (SQLException ex) {
System.err.println("Error" + ex);
}
}
//get connection, get celldata, get id data from first row, update cell with selected id
full controller class:
package simple;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TablePosition;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
/**
*
* #author admin
*/
public class FXMLUserController extends SimpleController implements Initializable {
#FXML
public TableView<UserDetails> tableview;
#FXML
public TableColumn<UserDetails, String> columnId;
#FXML
public TableColumn<UserDetails, String> columnType;
#FXML
public TableColumn<UserDetails, String> columnKleur;
#FXML
public TableColumn<UserDetails, String> columnLuchthaven;
#FXML
public TableColumn<UserDetails, String> columnKenmerken;
#FXML
public TableColumn<UserDetails, String> columnStatus;
#FXML
public TableColumn<UserDetails, String> columnDatum;
#FXML
private Button btnLoad;
//declare observable list for database data
private ObservableList<UserDetails> data;
private DbConnection dc;
String c1;
#FXML
//strings for getRow method
#Override
public void initialize(URL url, ResourceBundle rb) {
dc = new DbConnection();
loadDataFromDatabase();
}
#FXML
public void loadDataFromDatabase() {
try {
Connection conn = dc.Connect();
data = FXCollections.observableArrayList();
// Execute query and store result in a resultset
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM gevonden_bagage");
while (rs.next()) {
//get strings
data.add(new UserDetails(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5),
rs.getString(6), rs.getString(7)));
}
} catch (SQLException ex) {
System.err.println("Error" + ex);
}
//Set cell values to tableview.
tableview.setEditable(true);
tableview.getSelectionModel().setCellSelectionEnabled(true);
columnType.setCellFactory(TextFieldTableCell.forTableColumn());
columnKleur.setCellFactory(TextFieldTableCell.forTableColumn());
columnLuchthaven.setCellFactory(TextFieldTableCell.forTableColumn());
columnKenmerken.setCellFactory(TextFieldTableCell.forTableColumn());
columnStatus.setCellFactory(TextFieldTableCell.forTableColumn());
columnDatum.setCellFactory(TextFieldTableCell.forTableColumn());
//makes columns editable
columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
columnType.setCellValueFactory(new PropertyValueFactory<>("type"));
columnKleur.setCellValueFactory(new PropertyValueFactory<>("kleur"));
columnLuchthaven.setCellValueFactory(new PropertyValueFactory<>("luchthaven"));
columnKenmerken.setCellValueFactory(new PropertyValueFactory<>("kenmerken"));
columnStatus.setCellValueFactory(new PropertyValueFactory<>("status"));
columnDatum.setCellValueFactory(new PropertyValueFactory<>("datum"));
columnType.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<UserDetails, String>>() {
#Override
public void handle(TableColumn.CellEditEvent<UserDetails, String> event) {
updataData();
}
});
tableview.setItems(null);
tableview.setItems(data);
}
public void updataData() {
Connection connection = null;
try {
connection = DriverManager.getConnection("jdbc:mysql://37.128.148.113:3306/FYS", "FYS", "Kcj8g87~");
Statement con = connection.createStatement();
//connection
TablePosition pos = tableview.getSelectionModel().getSelectedCells().get(0);
int row = pos.getRow();
TableColumn col = pos.getTableColumn();
String data1 = (String) col.getCellObservableValue(row).getValue();
//cell
UserDetails row1 = tableview.getSelectionModel().getSelectedItem();
c1 = row1.getId();
//row
//tableview variables
con.execute("UPDATE gevonden_bagage SET type = 'data1' WHERE koffer_id = 'c1' ");
//Query
} catch (SQLException ex) {
System.err.println("Error" + ex);
}
}
//get connection, get celldata, get id data from first row, update cell with selected id
#FXML
public void getRow() {
TablePosition pos = tableview.getSelectionModel().getSelectedCells().get(0);
int row = pos.getRow();
TableColumn col = pos.getTableColumn();
// this gives the value in the selected cell:
String data1 = (String) col.getCellObservableValue(row).getValue();
System.out.println(data1);
//CURRENTLY UNUSED METHOD
}
}
Model class:
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
/**
*
* #author admin
*/
public class UserDetails {
private final StringProperty id;
private final StringProperty type;
private final StringProperty kleur;
private final StringProperty luchthaven;
private final StringProperty kenmerken;
private final StringProperty status;
private final StringProperty datum;
//Default constructor
public UserDetails(String id, String type, String kleur, String luchthaven, String kenmerken, String status, String datum) {
this.id = new SimpleStringProperty(id);
this.type = new SimpleStringProperty(type);
this.kleur = new SimpleStringProperty(kleur);
this.luchthaven = new SimpleStringProperty(luchthaven);
this.kenmerken = new SimpleStringProperty(kenmerken);
this.status = new SimpleStringProperty(status);
this.datum = new SimpleStringProperty(datum);
}
//getters
public String getId() {
return id.get();
}
public String getType() {
return type.get();
}
public String getKleur() {
return kleur.get();
}
public String getLuchthaven() {
return luchthaven.get();
}
public String getKenmerken() {
return kenmerken.get();
}
public String getStatus() {
return status.get();
}
public String getDatum() {
return datum.get();
}
//setters
public void setId(String value) {
id.set(value);
}
public void setType(String value) {
type.set(value);
}
public void setKleur(String value) {
kleur.set(value);
}
public void setLuchthaven(String value) {
luchthaven.set(value);
}
public void setKenmerken(String value) {
kenmerken.set(value);
}
public void setStatus(String value) {
status.set(value);
}
public void setDatum(String value) {
datum.set(value);
}
//property values
public StringProperty idProperty() {
return id;
}
public StringProperty typeProperty() {
return type;
}
public StringProperty kleurProperty() {
return kleur;
}
public StringProperty luchthavenProperty() {
return luchthaven;
}
public StringProperty kenmerkenProperty() {
return kenmerken;
}
public StringProperty statusProperty() {
return status;
}
public StringProperty datumProperty() {
return datum;
}
}
From the TableView documentation:
By default the TableColumn edit commit handler is non-null, with a
default handler that attempts to overwrite the property value for the
item in the currently-being-edited row. It is able to do this as the
Cell.commitEdit(Object) method is passed in the new value, and this is
passed along to the edit commit handler via the CellEditEvent that is
fired. It is simply a matter of calling
TableColumn.CellEditEvent.getNewValue() to retrieve this value.
It is very important to note that if you call
TableColumn.setOnEditCommit(javafx.event.EventHandler) with your own
EventHandler, then you will be removing the default handler. Unless
you then handle the writeback to the property (or the relevant data
source), nothing will happen.
So the problem is that by setting the onEditCommit on columnType, you remove the default handler that actually updates typeProperty in the UserDetails instance. Consequently
String data1 = (String) col.getCellObservableValue(row).getValue();
gives the old value, and your update to the database won't change anything.
Additionally, you have errors in the way you create the SQL statement. You are making the id in the WHERE clause the literal value 'c1' (instead of the value contained in the variable c1, and similarly setting the value of type to the literal value 'data1', instead of the value in the variable data1.
Here is a fix, along with some simplification of the code and some better practices for avoiding SQL injection attacks:
columnType.setOnEditCommit(event -> {
UserDetails user = event.getRowValue();
user.setType(event.getNewValue());
updateData("type", event.getNewValue(), user.getId());
});
and then
private void updateData(String column, String newValue, String id) {
// btw it is way better to keep the connection open while the app is running,
// and just close it when the app shuts down....
// the following "try with resources" at least makes sure things are closed:
try (
Connection connection = DriverManager.getConnection("jdbc:mysql://37.128.148.113:3306/FYS", "FYS", "Kcj8g87~");
PreparedStatement stmt = connection.prepareStatement("UPDATE gevonden_bagage SET "+column+" = ? WHERE koffer_id = ? ");
) {
stmt.setString(1, newValue);
stmt.setString(2, id);
stmt.execute();
} catch (SQLException ex) {
System.err.println("Error");
// if anything goes wrong, you will need the stack trace:
ex.printStackTrace(System.err);
}
}

how to read all date from PostgreSQL with array field jpa/hibernate ejb

i had problem to read all date from db PostgreSQL and jpa/hibernate ejb
my table has array field see below :
#Entity
public class MyTable{
private Long id;
private String name;
private String[] values;
#Type(type = "com.usertype.StringArrayUserType")
public String[] getValues(){
return values;
}
public void setValues(String[] values){
this.values = values;
}
}
and user type class like this :
package com.almasprocess.model.bl.en;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.UserType;
import java.io.Serializable;
import java.sql.*;
public class StringArrayUserType implements UserType {
protected static final int[] SQL_TYPES = { Types.ARRAY };
#Override
public Object assemble(Serializable cached, Object owner) throws HibernateException {
return this.deepCopy(cached);
}
#Override
public Object deepCopy(Object value) throws HibernateException {
return value;
}
#Override
public Serializable disassemble(Object value) throws HibernateException {
return (String[]) this.deepCopy(value);
}
#Override
public boolean equals(Object x, Object y) throws HibernateException {
if (x == null) {
return y == null;
}
return x.equals(y);
}
#Override
public int hashCode(Object x) throws HibernateException {
return x.hashCode();
}
#Override
public boolean isMutable() {
return true;
}
#Override
public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner)
throws HibernateException, SQLException {
if (resultSet.wasNull()) {
return null;
}
if(resultSet.getArray(names[0]) == null){
return new Integer[0];
}
Array array = resultSet.getArray(names[0]);
String[] javaArray = (String[]) array.getArray();
return javaArray;
}
#Override
public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session)
throws HibernateException, SQLException {
Connection connection = statement.getConnection();
if (value == null) {
statement.setNull(index, SQL_TYPES[0]);
} else {
String[] castObject = (String[]) value;
Array array = connection.createArrayOf("varchar", castObject);
statement.setArray(index, array);
}
}
#Override
public Object replace(Object original, Object target, Object owner) throws HibernateException {
return original;
}
#Override
public Class<String[]> returnedClass() {
return String[].class;
}
#Override
public int[] sqlTypes() {
return new int[] { Types.ARRAY };
}
}
and read date like this in ejb class :
public List readMailBank(){
String query = "select mt from mytable mt";
TypedQuery<StringArrayUserType> typedQuery = em.createQuery(query , StringArrayUserType.class);
List<StringArrayUserType> results = typedQuery.getResultList();
return results;
}
or like this sample code :
public List readMailBank(){
Type stringType = (Type) new TypeLocatorImpl(new TypeResolver()).custom(StringArrayUserType.class);
Query query = em.createNativeQuery("select mt from mytable mt");
query.unwrap(SQLQuery.class).addScalar("mb", (org.hibernate.type.Type) stringType);
List<Mailbank>results = query.getResultList();
return results;
}
but i had this error :
Caused by: java.lang.IllegalArgumentException: Type specified for TypedQuery [com.usertype.StringArrayUserType] is incompatible with query return type [class [Ljava.lang.String;]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.resultClassChecking(AbstractEntityManagerImpl.java:387) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:344) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.jboss.as.jpa.container.AbstractEntityManager.createQuery(AbstractEntityManager.java:131) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
please help me to read all data from db and fills array in to my array field?
thanks
I think the problem with your first example is that you try to create your query for values in Java which is a String[], but your JPQL asks for MyTable values. Which classes are not extending each other, thus you get an exception about the type incompatibility.
Something like
select mt.values from mytable mt
should give you what you want. (If it doesn't work at once, here is some documentation about selecting values instead of entities.)

Chaining filters with Objectify doesn't work

For some reason, I need to store my data in a Map and I don't want to declare each attribute of my objectify Entity one by one.
For instance, here is what my map would look like to:
"COMPANY_NAME" -> "something"
"TURNOVER_Min" -> 1000000 (a long value)
"CLIENT_STATUS"-> true (a boolean value)
And I would like to perform queries like that :
List<Lead> leads = ofy().load().type(Lead.class).filter("data.NET_INCOME_MIN >", 5.0).filter("data.NET_INCOME_MAX <", 100.0).list();
But I am getting no results although some data match this query...
I must tell you that it works for one filter at a tome...
It also works for several filters with "=" :
Here is my entity:
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
#Entity
public class Lead implements Serializable {
private static final long serialVersionUID = 5920146927107230150L;
#Id
private String url;
#Index
private Date dateCreated;
#Index
private Map<String, Object> data = new HashMap<>();
public Lead() {}
public Lead(String url) {
this.url = url;
this.dateCreated = new Date();
}
public void addData(String key, Object value) {
data.put(key, value);
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Date getDateCreated() {
return dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
public Map<String, Object> getData() {
return data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
}
Thank you very much
This is not your fault and not Objectify problem either.
As per the datastore documentation:
Inequality filters are limited to at most one property
To do what you want to do :
Use the first filter to retrieve only the keys of the entities ( use .keys() instead of .list() ).
Use the second filter to retrieve only the keys of the entities.
To perform the ANDing you need to get the intersection of the two key sets retrieved above.
Now as you have the keys of the entities you want and you can fetch the entities with a batch get operation.

Mixin annotation not getting honored when passed as a parameter

I have a third party class SpecialObject as:
public class SpecialObject {
private String name;
private Integer id;
private Date date;
public String getFoo() {return "foo";} //Outlier
public String getName() { return name;}
public Integer getId() {return id;}
public Date getDate() {return date;}
public void setName(String name) {this.name = name;}
public void setId(Integer id) {this.id = id;}
public void setDate(Date date) {this.date = date;}
}
I wish to only project out name and date properties when serializing it. Using the magic of MixinAnnotation from Jackson, I created a Mixin interface as:
#JsonAutoDetect(getterVisibility = Visibility.NONE)
public interface SpecialObjectMixin {
#JsonProperty
public String getName();
#JsonProperty
public Date getDate();
}
In order to facilitate handling of this SpecialObject as parameter, I have also defined a SpecialObjectHandler which implements the fromString() method.
#Override
public SpecialObject fromString(String json) {
try {
return objectMapper.readValue(json, SpecialObject.class);
} catch (IOException exception) {
throw new IllegalArgumentException("Unable to write JSON output",
exception);
}
}
When the deserializer invokes this method, the objectMapper throws an error as
Caused by: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "foo" (Class com.kilo.SpecialObject), not marked as ignorable
at [Source: java.io.StringReader#2d2217da; line: 1, column: 60] (through reference chain: com.kilo.SpecialObject["foo"])
at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659)
at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:1365)
at org.codehaus.jackson.map.deser.BeanDeserializer._handleUnknown(BeanDeserializer.java:725)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:703)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
at com.kilo.SpecialObjectHandler.fromString(SpecialObjectHandler.java:34)
My question is that is there a way that I can have the objectMapper (org.codehaus.jackson.map.ObjectMapper) also honor annotations from the Mixin where I had configured it to only deal with name and date? Feel free to point out something elementary that I may have overlooked. Thanks in advance!
It was a problem with configuration. The mixin was only set on the serialization config and not on the deserialization config causing the issue. Setting it on both configs solves the problem.

Resources