I realize this has been asked before, but I can't seem to find an answer and I've been looking all day. I have the following unit test which always seems to throw an ArrayStoreException when calling the getResultList() method on my query.
Code:
@Entity
@RooEntity
@NamedNativeQuery(name="Mileage.calculateMileage",
query = "{ call logobj.milookup(?,?,?) }",
hints = {
@QueryHint(name = "org.hibernate.callable", value = "true"),
@QueryHint(name = "org.hibernate.readOnly", value = "true")
},
resultClass = MileageTest.class)
public class MileageTest {
private static Log log = LogFactory.getLog(MileageTest.class);
@Column(name = "PMMILES")
private String miles;
@Test
public void calculateMileage() {
Map<String,String> args = new HashMap<String,String>();
// args values are set here.
EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistenceUnit", args);
EntityManager em = emf.createEntityManager();
Query query = em.createNamedQuery("Mileage.calculateMileage");
query.setParameter(2, "TORONTO ON");
query.setParameter(3, "MONTREAL QC");
if(log.isInfoEnabled())
log.info(query.getResultList());
}
}
My stored procedure has 3 parameters. The first is an OUT parameter and the rest are IN parameters. The procedure takes the 2 IN parameters which are cities, calculates the miles between then and returns the result in the OUT parameter.
Anybody know why it keeps throwing this exception? I've tried switching between a Hibernate NamedNativeQuery and a JPA NamedNativeQuery, but I always get the same exception.