JBoss version:4.0.4
Hibernate version:3.2
Database:Oracle10g
Hi. I am facing an entity mapping problem. I have an Oracle stored function which takes as a parameter an Oracle array and returns a refcursor. And I want to map the returning result to an entity class. I have created the entity class as follows:
@Entity
@SqlResultSetMapping(name = "flightBaggageSummaryMapping",
entities = @EntityResult(entityClass = FlightBaggageSummary.class))
@NamedNativeQuery(name = "flightBaggageSummaryQuery",
query = "{?=call MULTI_FLIGHT_PAX_AND_BAG_COUNT(:flightList)}",
resultSetMapping = "flightBaggageSummaryMapping",
hints = {@QueryHint(name = "org.hibernate.callable", value = "true"),
@QueryHint(name = "org.hibernate.readOnly", value = "true")})
public class FlightBaggageSummary implements Serializable
{
private static final long serialVersionUID = 1;
private long flightId;
private long checkedInBags;
private long loadedBaggageHallBags;
@Id
public long getFlightId()
{
return flightId;
}
public void setFlightId(long flightId)
{
this.flightId=flightId;
}
// Accessors and mutators and @Column annotations here
...
}
And in a Facade, I have the following method:
public List<FlightBaggageSummary> getFlightBaggageSummary(Long[] flightIds) throws ApplicationTierException
{
// Validate parameter
if (flightIds == null || flightIds.length == 0)
{
throw new IllegalArgumentException();
}
ARRAY arrayOfFlightIds = null;
try
{
// The datasource is a member variable of the Facade
Connection connection = ((WrappedConnection)dataSource.getConnection()).ge tUnderlyingConnection();
// FLIGHT_LIST is the Oracle array type that is passed as aparameter in the stored function
ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor("FLIGHT_LIST", connection);
arrayOfFlightIds = new ARRAY(arrayDescriptor, connection, flightIds);
}
catch (SQLException e)
{
throw new ApplicationTierException(e);
}
Query query = entityManager.createNamedQuery("flightBaggageSumma ryQuery").setParameter("flightList", arrayOfFlightIds);
return (List<FlightBaggageSummary>) query.getResultList();
}
to get information about flights & I get following exception:
(Exception in next post)