Results 1 to 5 of 5
  1. #1
    narayanrec is offline Member
    Join Date
    Jan 2008
    Posts
    4
    Rep Power
    0

    Question 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.

    Please help.

  2. #2
    maruthi_s is offline Member
    Join Date
    Jan 2008
    Posts
    20
    Rep Power
    0

    Default

    That should not be the case.. Can you paste the errors/exception you got.

  3. #3
    narayanrec is offline Member
    Join Date
    Jan 2008
    Posts
    4
    Rep Power
    0

    Default 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

  4. #4
    maruthi_s is offline Member
    Join Date
    Jan 2008
    Posts
    20
    Rep Power
    0

    Default

    just checking ... did changing the annotations helped ..

  5. #5
    narayanrec is offline Member
    Join Date
    Jan 2008
    Posts
    4
    Rep Power
    0

    Default

    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.

Similar Threads

  1. Annotations
    By yogesh_SC in forum Advanced Java
    Replies: 1
    Last Post: 04-02-2009, 09:33 PM
  2. Replies: 0
    Last Post: 01-02-2008, 04:24 AM
  3. @ annotations
    By mew in forum New To Java
    Replies: 1
    Last Post: 12-12-2007, 11:04 AM
  4. Hibernate subclasses
    By Ed in forum JDBC
    Replies: 2
    Last Post: 07-02-2007, 04:42 PM
  5. Tables In Ejb3
    By Alan in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 05-10-2007, 04:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •