Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1887

eclipse bytecode enhancer ignoring annotations

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2.2, 2.0.1
    • None
    • Enhance
    • None
    • windows xp, eclipse 3.5 bytecode enhance OpenJPA Eclipse Feature 1.0.0.201001181728
      OpenJPA 1.2.2

    Description

      This is long and very detailed as it is the result of a discussion on http://openjpa.208410.n2.nabble.com/beans-Enitiy-annotation-and-bytcode-enhancement-td5380244.html#a5744274

      when i use the eclipse bytecode enhancer the annotation @Entity(name="testTable") is ignored and all youhave available if the class name

      BEAN:
      @Entity(name="testTable")
      @Table(name = "cocktails")
      public class TestBean implements IBean{

      Integer id;
      String data1;

      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "id", unique = true, nullable = false)
      public Integer getId()

      { return id; }

      public void setId(Integer id_)

      { id = id_; }

      @Column(name="name")
      public String getData1()

      { return data1; }

      public void setData1(String data1_)

      { data1 = data1_; }

      }

      DAO:
      public class TestDAO extends BaseDAO<TestBean> {

      @Override
      public List<TestBean> findAll()

      { return findAll("testTable"); }

      }

      main:
      public static void main(String[] args) {
      TestDAO dao = new TestDAO();
      List<TestBean> findAll = dao.findAll();
      for (TestBean testBean : findAll)

      { System.out.println(testBean.getData1()); }

      }

      persistence.xml:
      <persistence-unit name="TestPU"
      transaction-type="RESOURCE_LOCAL">
      <provider>
      org.apache.openjpa.persistence.PersistenceProviderImpl
      </provider>
      <class>com.test.dao.Cocktail</class>
      <class>com.test.dao.TestBean</class>
      ...

      creating a main and selecting from TestBean (no enhancement) i get:

      16-Nov-2010 15:42:03 com.test.dao.EntityManagerHelper log
      INFO: finding allTest
      110 TestPU INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.2
      250 TestPU INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary".
      781 TestPU INFO [main] openjpa.Enhance - Creating subclass for "[class com.test.dao.Cocktail, class com.test.dao.TestBean]". This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead.
      1594 TestPU TRACE [main] openjpa.jdbc.SQL - <t 31212095, conn 25254907> executing prepstmnt 21465667 SELECT t0.id, t0.name, t0.activeYN FROM cocktails t0 ORDER BY t0.id ASC
      1610 TestPU TRACE [main] openjpa.jdbc.SQL - <t 31212095, conn 25254907> [16 ms] spent

      running using the runtime enhancer: (putting -javaagent:C:\JavaProjects\OpenJpaTest\WebContent\WEB-INF\lib\openjpa-1.2.2.jar in the run configuration arguments)
      16-Nov-2010 15:44:11 com.test.dao.EntityManagerHelper log
      INFO: finding allTest
      141 TestPU INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.2
      235 TestPU INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary".
      1829 TestPU TRACE [main] openjpa.jdbc.SQL - <t 3841429, conn 4176892> executing prepstmnt 30702379 SELECT t0.id, t0.name, t0.activeYN FROM cocktails t0 ORDER BY t0.id ASC
      1860 TestPU TRACE [main] openjpa.jdbc.SQL - <t 3841429, conn 4176892> [31 ms] spent

      And using the eclipse bytecode enhancer plugin:

      16-Nov-2010 15:45:32 com.test.dao.EntityManagerHelper log
      INFO: finding allTest
      109 TestPU INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.2
      250 TestPU INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary".
      16-Nov-2010 15:45:33 com.test.dao.EntityManagerHelper log
      SEVERE: find all failed name failed
      <openjpa-1.2.2-r422266:898935 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "select model from testTable model order by model.id". Error message: The name "testTable" is not a recognized entity or identifier. Perhaps you meant TestBean, which is a close match. Known entity names: [TestBean, Cocktail]
      at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118) .

      Trying now with the latest version of openjpa jar tested with openJPA 2.0.1, and this also fails

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            wendyg wendy gibbons

            Dates

              Created:
              Updated:

              Slack

                Issue deployment