473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Oracle Array - Entity mapping problem - Could not serialize

168 100+
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)
Feb 7 '07 #1
1 2700
rengaraj
168 100+
Stack trace:javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.type.SerializationException: could not serialize
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOu rTx(Ejb3TxPolicy.java:69)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPoli cy.java:83)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke (TxInterceptor.java:197)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invo ke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceIntercep tor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.aspects.security.RoleBasedAuthorizationI nterceptor.invoke(RoleBasedAuthorizationIntercepto r.java:167)
at org.jboss.ejb3.security.RoleBasedAuthorizationInte rceptor.invoke(RoleBasedAuthorizationInterceptor.j ava:100)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationIntercept or.invoke(AuthenticationInterceptor.java:78)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(EN CPropagationInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousIntercepto r.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.localI nvoke(StatelessContainer.java:181)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invok e(StatelessLocalProxy.java:79)
at $Proxy107.getFlightBaggageSummary(Unknown Source)
at com.app.web.delegates.FlightServicesDelegate.getFl ightBaggageSummary(FlightServicesDelegate.java:202 )
at com.app.web.servlets.flight.FlightLoopServlet.doGe t(FlightLoopServlet.java:213)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at com.app.web.filters.EncodingFilter.doFilter(Encodi ngFilter.java:110) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at com.app.web.filters.FlightLoopFilter.doFilter(Flig htLoopFilter.java:112) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at com.app.web.filters.UserContextFilter.doFilter(Use rContextFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:524)
at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread .run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.persistence.PersistenceException: org.hibernate.type.SerializationException: could not serialize
at org.hibernate.ejb.AbstractEntityManagerImpl.throwP ersistenceException(AbstractEntityManagerImpl.java :567)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImp l.java:56)
at com.ultra_as.ultratrak.application.services.Flight ServiceFacadeBean.getFlightBaggageSummary(FlightSe rviceFacadeBean.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.p roceed(InvocationContextImpl.java:166)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterce ptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManag erInterceptor.invoke(TransactionScopedEntityManage rInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke (AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPoli cy.java:79)
... 50 more
Caused by: org.hibernate.type.SerializationException: could not serialize
at org.hibernate.util.SerializationHelper.serialize(S erializationHelper.java:158)
at org.hibernate.util.SerializationHelper.serialize(S erializationHelper.java:178)
at org.hibernate.type.SerializableType.toBytes(Serial izableType.java:74)
at org.hibernate.type.SerializableType.toString(Seria lizableType.java:58)
at org.hibernate.type.NullableType.nullSafeSet(Nullab leType.java:87)
at org.hibernate.type.NullableType.nullSafeSet(Nullab leType.java:65)
at org.hibernate.loader.Loader.bindNamedParameters(Lo ader.java:1748)
at org.hibernate.loader.Loader.prepareQueryStatement( Loader.java:1577)
at org.hibernate.loader.Loader.doQuery(Loader.java:66 1)
at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:214 5)
at org.hibernate.loader.Loader.listIgnoreQueryCache(L oader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(Cust omLoader.java:118)
at org.hibernate.impl.SessionImpl.listCustomQuery(Ses sionImpl.java:1684)
at org.hibernate.impl.AbstractSessionImpl.list(Abstra ctSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl. java:164)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImp l.java:53)
... 64 more
Caused by: java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unkn own Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unk nown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at org.hibernate.util.SerializationHelper.serialize(S erializationHelper.java:154)
... 81 more

The exception occurs when the return statement of the getFlightBaggageSummary method is called. I'm a bit stuck to be honest. I'm converting a java array of Longs to an Oracle ARRAY object but it doesn't seem to work. I can't figure out from the exception where could be the problem.
The Oracle stored function takes a parameter of type FLIGHT_LIST.

The type is defined as follows:
create or replace TYPE flight_list AS TABLE OF NUMBER(10)

Could anyone tell me if there is a way to pass my Long[] and set the named parameter of the named native query? I managed to get it working with plain JDBC and a Callable Statement but I'd like to do it with an entity mapping.
Thanks in advance for any help.
Feb 7 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour,...
8
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city ...
6
by: Vincent Lefevre | last post by:
I would like to know if the base URI considered to resolve an unparsed entity defined by a relative URI should be the URI before or after its rewriting due to a possible catalog. Let's take an...
8
by: danbredy | last post by:
Hi, I'm attempting to connect to an Oracle database using SQL Server 2005 Express (OS is Windows XP Professional) and having absolutely no luck. Here is the information SQL Plus gives me about...
11
by: Jean-François Michaud | last post by:
Hello all, I'm having a little problem, The UTF-8 parser we are using converts the newline entity ( ) within an attribute that we are using to paliate CSS limitations. After the parser has...
4
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
5
by: =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post by:
Hi Willy, Thank you very much for your work. C++ code doesnot make any serialization. So at runtime C# code gives an serialization error at "msg_file_s sa = (msg_file_s) bf.Deserialize(ms);"...
3
by: chris.kennedy | last post by:
I am really struggling to create an entity which maps to 2 "base" entities. I have a customer and invoice entity which are based in tables in a one to many relationship. I have tried: 1....
1
by: markla | last post by:
Hi, I have an Entity data model built in Entity Framework, which sources data primarily from an MS SQL 2008 database, and sources some static (data dictionary) values from code-based objects. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.