Hi, from searching the forums I know loads of people have struggled with this but I can't seem to get it to work either.
I have an application that is storing historic stock market price data for a range of items. The amount of data available for each item varies so what I was planning to do was store the data as a double[] in a single column keyed on the item code. In other words a class like this:
Code:
public class Item {
private int key;
private double[] data;
... other stuff...
}
An initial test run with three points of data worked fine. The Item table was created with the data column as a varbinary(255) on MS SQL Server 2005. I then tried again with 60 points of data and it failed because, of course, the data would be truncated.
To try to get round this I annotated the data field with @Lob which caused the data column to change type to "image" (which I presume is a SQL Server BLOB). Unfortunately I can't seem to insert any data into the table now. The insert just fails with this unhelpful exception:
Code:
javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.enterprise.transaction.JavaEETransactionImpl.commit(JavaEETransactionImpl.java:436) [na:na]
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:843) [na:na]
the code doing the insert is:
Code:
try {
utx.begin();
EntityManager em = emf.createEntityManager();
em.persist( item );
utx.commit();
} catch( Exception e ) {
logger.error( "Failed to persist item: " + data, e );
throw new DataStoreException( "Failed to persist item: " + data, e );
}
I realize that storing an array of data in a single column means the data isn't normalized but I need to store roughly 500 million points of data and all accesses are whole-item-at-a-time only. I don't think a separate table storing a point of data per row would be quick enough and a wide table won't work because I don't know how many data points each row will have.
I really hope someone can help because not finding a solution to this problem means going back and hacking on the horrific piece of code that is currently running! :-D