Issue Details (XML | Word | Printable)

Key: NUCHBASE-84
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Luciano Curioni
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Store HBase

Cannot retrieve Integer fields since changes on plugin.xml in datanucleus-core with commit r16924 (http://sourceforge.net/p/datanucleus/code/16924/)

Created: 29/Aug/13 08:49 PM   Updated: 19/Nov/13 10:29 AM   Resolved: 01/Sep/13 02:54 PM
Component/s: Persistence
Affects Version/s: 3.2.2
Fix Version/s: 3.2.3

Environment: Teste on OSX and HBase 0.94.11

Datastore: HBase
Severity: Production


 Description  « Hide
After storing an Integer field on HBase it is not possible to retrieve it. Datanucleus find that the stored field is a Strng while it is already a Integer object. The Exception and partial stack is:
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at org.datanucleus.store.hbase.fieldmanager.FetchFieldManager.fetchObjectField(FetchFieldManager.java:413)
at org.datanucleus.state.JDOStateManager.replacingObjectField(JDOStateManager.java:2172)
at org.datanucleus.samples.jdo.tutorial.Book.jdoReplaceField(Book.java)
at org.datanucleus.samples.jdo.tutorial.Product.jdoReplaceFields(Product.java)
at org.datanucleus.state.JDOStateManager.replaceFields(JDOStateManager.java:3410)
at org.datanucleus.state.JDOStateManager.replaceFields(JDOStateManager.java:3437)
at org.datanucleus.store.hbase.HBasePersistenceHandler.fetchObject(HBasePersistenceHandler.java:713)

This test was done with datanucleus-core and datanucleus-hbase on the SVN trunk and also the latest releases versions.
The issue sounds very similar to NUCMONGODB-122, but with HBase

Please let me know how I can help.

This can be easily reproduced with a patch to the jdo-sample against a HBase database. The patch is:

diff --git a/src/main/java/org/datanucleus/samples/jdo/tutorial/Book.java b/src/main/java/org/datanucleus/samples/jdo/tutorial/Book.java
index 2e60c84..0546239 100644
--- a/src/main/java/org/datanucleus/samples/jdo/tutorial/Book.java
+++ b/src/main/java/org/datanucleus/samples/jdo/tutorial/Book.java
@@ -18,6 +18,7 @@
 package org.datanucleus.samples.jdo.tutorial;
 
 import javax.jdo.annotations.PersistenceCapable;
+import javax.jdo.annotations.Persistent;
 
 /**
  * Definition of a Book. Extends basic Product class.
@@ -30,6 +31,17 @@
     protected String isbn=null;
 
     protected String publisher=null;
+
+ @Persistent
+ protected Integer pages;
+
+ public Integer getPages() {
+ return pages;
+ }
+
+ public void setPages(Integer pages) {
+ this.pages = pages;
+ }
 
     public Book(String name, String description, double price, String author, String isbn, String publisher)
     {
@@ -71,6 +83,6 @@
 
     public String toString()
     {
- return "Book : " + author + " - " + name;
+ return "Book : " + author + " - " + name + " - " + pages;
     }
 }
\ No newline at end of file
diff --git a/src/main/java/org/datanucleus/samples/jdo/tutorial/Main.java b/src/main/java/org/datanucleus/samples/jdo/tutorial/Main.java
index 778fa4e..0b89362 100644
--- a/src/main/java/org/datanucleus/samples/jdo/tutorial/Main.java
+++ b/src/main/java/org/datanucleus/samples/jdo/tutorial/Main.java
@@ -53,6 +53,7 @@
             Inventory inv = new Inventory("My Inventory");
             Product product = new Product("Sony Discman","A standard discman from Sony",200.00);
             Book book = new Book("Lord of the Rings by Tolkien","The classic story",49.99,"JRR Tolkien", "12345678", "MyBooks Factory");
+ book.setPages(314);
             inv.getProducts().add(product);
             inv.getProducts().add(book);
             pm.makePersistent(inv);
diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml
index f5dbe0e..2c69c9e 100644
--- a/src/main/resources/META-INF/persistence.xml
+++ b/src/main/resources/META-INF/persistence.xml
@@ -11,11 +11,11 @@
         <exclude-unlisted-classes/>
         <properties>
             <!-- ENABLE THESE FOR H2 -->
- <property name="javax.jdo.option.ConnectionURL" value="jdbc:h2:mem:nucleus1"/>
+ <!-- <property name="javax.jdo.option.ConnectionURL" value="jdbc:h2:mem:nucleus1"/>
             <property name="javax.jdo.option.ConnectionDriverName" value="org.h2.Driver"/>
             <property name="javax.jdo.option.ConnectionUserName" value="sa"/>
             <property name="javax.jdo.option.ConnectionPassword" value=""/>
- <property name="javax.jdo.option.Mapping" value="h2"/>
+ <property name="javax.jdo.option.Mapping" value="h2"/> -->
 
             <!-- ENABLE THESE FOR HSQLDB -->
             <!--property name="javax.jdo.option.ConnectionURL" value="jdbc:hsqldb:mem:nucleus1"/>
@@ -41,7 +41,8 @@
             <!--property name="javax.jdo.option.ConnectionURL" value="mongodb:/nucleus1"/-->
 
             <!-- ENABLE THESE FOR HBASE -->
- <!--property name="javax.jdo.option.ConnectionURL" value="hbase:"/-->
+ <property name="javax.jdo.option.ConnectionURL" value="hbase:"/>
+ <property name="datanucleus.cache.level2.type" value="none" />
 
             <!-- ENABLE THESE FOR NEO4J -->
             <!--property name="javax.jdo.option.ConnectionURL" value="neo4j:testDB"/-->

Andy Jefferson added a comment - 30/Aug/13 02:37 PM
The DN tutorial is not a testcase. Please follow the standard reporting guide which offers ample flexibility. Thx
http://www.datanucleus.org/project/problem_reporting.html

Better still, actually state what you see as the problem. MongoDB plugin was storing things incorrectly (i.e allowing things to fall back to core handling when the datastore didn't warrant that). The datastore plugin is responsible for managing such things itself; the additional feature in core provides extra capabilities, so it is up to datastore plugins to use them or not. When you've done that you could just grab the code for the plugin and contribute a patch to fix whatever you're seeing

Andy Jefferson added a comment - 01/Sep/13 02:54 PM
Since there is no provided way of seeing this, I presume it works in 3.2.3

Andy Jefferson made changes - 01/Sep/13 02:54 PM
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 3.2.3 [ 12023 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 19/Nov/13 10:29 AM
Status Resolved [ 5 ] Closed [ 6 ]