Can I use annotations in superclass, and .cfg.xml files in subclasses in EJB3

Hi,

There is a common project, to which my application is going to interact. The common application is in JPA-using annotations in the model classes. Some of the model classes in my application is going to extend the common project's model classes. But my application uses .cfg.xml files for the model classes. So do I have to change the hibernate configuration files to annotations in my application, to make it work with common project?

I tried running a Junit, without changing the configuration files to annotations, but I am encountering errors in query. So I guess, this might be the problem - that I have to change the hibernate configuration files to annotations.

I tried a lot of options but to no avail. See the error below.

java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [OLPARAM]
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl .java:185)
at com.bp.mobo.pricechecker.HibernateTestCase.loadGra deByName(HibernateTestCase.java:80)
at com.bp.mobo.pricechecker.HibernateTestCase.getGrad eId(HibernateTestCase.java:86)
at com.bp.mobo.pricechecker.server.dal.RequiredPriceD aoTestCase.setUp(RequiredPriceDaoTestCase.java:50)
at junit.framework.TestCase.runBare(TestCase.java:125 )
at junit.framework.TestResult$1.protect(TestResult.ja va:106)
at junit.framework.TestResult.runProtected(TestResult .java:124)
at junit.framework.TestResult.run(TestResult.java:109 )
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit 3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.QueryParameterException: could not locate named parameter [OLPARAM]
at org.hibernate.engine.query.ParameterMetadata.getNa medParameterDescriptor(ParameterMetadata.java:75)
at org.hibernate.engine.query.ParameterMetadata.getNa medParameterExpectedType(ParameterMetadata.java:81 )
at org.hibernate.impl.AbstractQueryImpl.determineType (AbstractQueryImpl.java:413)
at org.hibernate.impl.AbstractQueryImpl.setParameter( AbstractQueryImpl.java:383)
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl .java:180)
... 16 more

Actually the base class was using annotations, and the super classs was using .hbm.xml file for mapping with the database. In this case I don't require the base class annotations, as my super class takes care of mapping all the database columns. So I removed the annotations from the base class and tried executing the Junit, but to no use. It still complains the same thing. Now its the case that even .hbm.xml files are not working with Entity Manager. The next option for me would be to change to annotations and remove .hbm.xml files. But I don't see any reason why this shouldn't work, and moreover its additional effort to convert to annotations.