-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Inheritence and hibernate mapping problem
PostPosted: Wed May 13, 2009 1:06 pm 
Newbie

Joined: Thu Mar 19, 2009 8:19 pm
Posts: 12
Hello,

I have an abstract class called AbstractActivity that doesn't map to any tables. I have two concrete classes AActivity and BActivity that map to two separate tables.

Here is the mapping of AActivity

Code:
<hibernate-mapping package="com.mda.acms.database.persistence.hb">
   <class name="AActivity" table="aac_activity" >
      <id name="id" type="java.lang.Integer" unsaved-value="null">
         <column name="id" />
         <generator class="sequence">
            <param name="sequence">aac_activity_seq</param>
         </generator>
      </id>
      <property name="emailAddress" type="string">
         <column name="email_address" length="200" />
      </property>
</class>
   <query name="AcquisitionActivity.testQuery">
       <![CDATA[
         some query
      ]]>
   </query>
</hibernate-mapping>


I have a very similar mapping for BActivity. I want to keep these two entities separate in db.

Now here is the code for AActivity:

Code:
public class AActivity extends AbstractActivity
{

    private String emailAddress //with getters and setters

     public AActivity()
    {
        super();
     }

}



and here is the code for AbstractActivity

Code:
public abstract class AbstractActivity implements Serializable
{
  private Integer id; //with getters and setters

}



Now when i create an object from AActivity or BActivity and save it, there is no problem, everything is saved in db.

but I get an exception if i try to call any queries in AActivity's or BActivity's mapping file. Here is the exception:

Code:
09:27:16,195 INFO  [AcquisitionActivityManagerEjb] Error: null
09:27:16,195 ERROR [STDERR] java.lang.reflect.UndeclaredThrowableException
09:27:16,195 ERROR [STDERR]    at $Proxy80.getNamedQuery(Unknown Source)
09:27:16,195 ERROR [STDERR]    at com.mda.acms.database.activity.ejb.AcquisitionActivityManagerEjb.findRequiresManualCheckActivities(Unknown Source)
09:27:16,195 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
09:27:16,195 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
09:27:16,195 ERROR [STDERR]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
09:27:16,195 ERROR [STDERR]    at java.lang.reflect.Method.invoke(Method.java:585)
09:27:16,195 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
09:27:16,195 ERROR [STDERR]    at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
09:27:16,195 ERROR [STDERR]    at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
09:27:16,195 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,195 ERROR [STDERR]    at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:
54)
09:27:16,195 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,195 ERROR [STDERR]    at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:46)
09:27:16,195 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,195 ERROR [STDERR]    at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
09:27:16,195 ERROR [STDERR]    at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:262)
09:27:16,195 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,195 ERROR [STDERR]    at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
09:27:16,195 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,195 ERROR [STDERR]    at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
09:27:16,195 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,195 ERROR [STDERR]    at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
09:27:16,195 ERROR [STDERR]    at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
09:27:16,211 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,211 ERROR [STDERR]    at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
09:27:16,211 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,211 ERROR [STDERR]    at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
09:27:16,211 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,211 ERROR [STDERR]    at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:263)
09:27:16,211 ERROR [STDERR]    at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
09:27:16,211 ERROR [STDERR]    at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
09:27:16,211 ERROR [STDERR]    at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
09:27:16,211 ERROR [STDERR]    at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
09:27:16,211 ERROR [STDERR]    at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
09:27:16,211 ERROR [STDERR]    at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
09:27:16,211 ERROR [STDERR]    at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
09:27:16,211 ERROR [STDERR] Caused by: org.jboss.serial.exception.SerializationException: Could not create instance of org.hibernate.impl.QueryImpl -
org.hibernate.impl.QueryImpl
09:27:16,211 ERROR [STDERR]    at org.jboss.serial.classmetamodel.ClassMetaData.newInstance(ClassMetaData.java:342)
09:27:16,211 ERROR [STDERR]    at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:239)
09:27:16,211 ERROR [STDERR]    at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.ja
va:412)
09:27:16,211 ERROR [STDERR]    at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
09:27:16,211 ERROR [STDERR]    at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:845)
09:27:16,211 ERROR [STDERR]    at org.jboss.serial.io.MarshalledObjectForLocalCalls.get(MarshalledObjectForLocalCalls.java:60)
09:27:16,211 ERROR [STDERR]    at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:73)
09:27:16,211 ERROR [STDERR]    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
09:27:16,211 ERROR [STDERR]    at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
09:27:16,211 ERROR [STDERR]    ... 36 more
09:27:16,211 ERROR [STDERR] Caused by: java.lang.InstantiationException: org.hibernate.impl.QueryImpl
09:27:16,211 ERROR [STDERR]    at java.lang.Class.newInstance0(Class.java:335)
09:27:16,211 ERROR [STDERR]    at java.lang.Class.newInstance(Class.java:303)
09:27:16,211 ERROR [STDERR]    at org.jboss.serial.classmetamodel.ClassMetaData.newInstance(ClassMetaData.java:334)
09:27:16,211 ERROR [STDERR]    ... 44 more


Does "java.lang.InstantiationException: org.hibernate.impl.QueryImpl " mean that hibernate cannot understand the way my code is structured and hence cannot instantiate it?


I also tried

Code:
public class AActivity extends AbstractActivity implements Serializable


but no luck.

Any ideas?

thanks in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.