[jira] [Commented] (SOLR-6539) SolrJ document object binding / BigDecimal

2015-01-11 Thread Erik Hatcher (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-6539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14273149#comment-14273149
 ] 

Erik Hatcher commented on SOLR-6539:


[~bertbrecht42] - the .diff attached is not a compiling patch (it misses an 
import, for example, but even then it doesn't compile because the valueOf() 
isn't being passed the right type.  I was going to pick this up and get this 
into 5x, but I don't use the SolrJ bindings and won't tinker with this without 
at least a compiling patch.  A test case would be handy to be sure this is 
doing the right thing as well. 

 SolrJ document object binding / BigDecimal
 --

 Key: SOLR-6539
 URL: https://issues.apache.org/jira/browse/SOLR-6539
 Project: Solr
  Issue Type: Improvement
  Components: SolrJ
Affects Versions: 4.9, 4.10, 4.10.1
Reporter: Bert Brecht
  Labels: patch
 Fix For: Trunk

 Attachments: SOLR-6539.diff


 We are using BigDecimals in our application quite often for calculating. We 
 store our values typically as java primitives (int, long/double, float) and 
 using the DocumentObjectBinder (annotations based document object binding). 
 Unfortunately, we must have exactly the type given in solr schema for type 
 used as field/accessor. We found out, that the following patch would allow us 
 to define BigDecimal as type as we just use BigDecimal as a type in our 
 mapped POJO. This would help to make the mapping more powerful without 
 loosing anything.
 --
 $ svn diff 
 Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
 Index: 
 Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
 ===
 --- 
 Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
  (revision 1626087)
 +++ 
 Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
  (working copy)
 @@ -359,6 +359,9 @@
if (v != null  type == ByteBuffer.class  v.getClass() == 
 byte[].class) {
  v = ByteBuffer.wrap((byte[]) v);
}
 +  if (type == java.math.BigDecimal.class){
 +v = BigDecimal.valueOf(v):
 +  }
try {
  if (field != null) {
field.set(obj, v);



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-6539) SolrJ document object binding / BigDecimal

2014-11-15 Thread Erik Hatcher (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-6539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14213673#comment-14213673
 ] 

Erik Hatcher commented on SOLR-6539:


Bert - could you also include a test case that demonstrates the problem and 
passes after your fix? 

 SolrJ document object binding / BigDecimal
 --

 Key: SOLR-6539
 URL: https://issues.apache.org/jira/browse/SOLR-6539
 Project: Solr
  Issue Type: Improvement
  Components: SolrJ
Affects Versions: 4.9, 4.10, 4.10.1
Reporter: Bert Brecht
  Labels: patch
 Fix For: 4.10.3, 5.0, Trunk

 Attachments: SOLR-6539.diff


 We are using BigDecimals in our application quite often for calculating. We 
 store our values typically as java primitives (int, long/double, float) and 
 using the DocumentObjectBinder (annotations based document object binding). 
 Unfortunately, we must have exactly the type given in solr schema for type 
 used as field/accessor. We found out, that the following patch would allow us 
 to define BigDecimal as type as we just use BigDecimal as a type in our 
 mapped POJO. This would help to make the mapping more powerful without 
 loosing anything.
 --
 $ svn diff 
 Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
 Index: 
 Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
 ===
 --- 
 Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
  (revision 1626087)
 +++ 
 Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
  (working copy)
 @@ -359,6 +359,9 @@
if (v != null  type == ByteBuffer.class  v.getClass() == 
 byte[].class) {
  v = ByteBuffer.wrap((byte[]) v);
}
 +  if (type == java.math.BigDecimal.class){
 +v = BigDecimal.valueOf(v):
 +  }
try {
  if (field != null) {
field.set(obj, v);



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org