| 
					
						 Hello,
  I'm using jpa 2.0 with hibernate persistence provider and I'm trying to call a stored procedure with a custom type parameter (represented in oracle as a type of array of another type). I can't find any working example of how this can be accomplished. 
  What I've done so far: 1. Annotated my entity with 	@org.hibernate.annotations.NamedNativeQuery(name = "TESTPROCEDURE", 							query = "call TESTPROCEDURE(?, :block_array, :ID)", 							callable = true, readOnly = true, 							resultClass=ResultMappingSP.class)
  2. Created an object that will compose the array Block 3. Created a class that implements UserType, Block_Array_Type and implemented nullSafeGet/nullSafeSet
      @Override     public Object nullSafeGet(ResultSet rs, String[] names, Object arg2) throws HibernateException, 	    SQLException { 	Array array = rs.getArray(names[0]); 	Block[] javaArray = (Block[]) array.getArray(); 	return javaArray;     }
      @Override     public void nullSafeSet(PreparedStatement st, Object value, int index) 	    throws HibernateException, SQLException { 	if (value == null) 	    st.setNull(index, 0); 	else { 	    st.setArray(index, (Array) value); 	}     }
 
  However I can't figure out how to call the named query, I'm thinking something like (where array is a Block[] ):         Query query = em.createNamedQuery("TESTPROCEDURE"); 	query.setParameter(block_array, array); 	query.setParameter("ID", id); 				 	return (ResultMappingSP) query.getSingleResult();
  The above code does not work. Please help. Thank you 
					
  
						
					 |