Search code examples
openjpa

OpenJPA executing prepared statement when none exist in the project


I have web project in which I am using OpenJAP for database connectivity. I have configured the persistence.xml and I am able to connect to the database and retrieve the data. But in the console output I am seeing this entry

1953  OpenJPA  TRACE  [main] openjpa.jdbc.SQL - <t 31156635, conn 6888942> executing prepstmnt 9690924 

UPDATE student 
    SET scourse = ?, sname = ?, sroll = ? 
    WHERE id = ? 
[params=?, ?, ?, ?]

In my whole project till now I have not added any prepared statement or any update statement. I want to know why is OpenJPA executing this statement and what would be performance implication when I am fetching big data in the range of millions?


Solution

  • I have added following code to my build.xml file

    <!-- ***************************************************************************************************************** -->
    <!-- DO NOT DELETE FOLLOWING CODE. THIS IS ADDED FOR ENCHANCING THE CLASSES AT COMPILE TIME. IT IS REQUIRED BY OPENJPA -->
    <!-- Define the classpath to include the necessary files. -->
    <!-- ex. openjpa jars, persistence.xml, orm.xml, and target classes  -->
    <path id="jpa.enhancement.classpath">
        <!-- Assuming persistence.xml/orm.xml are in WebContent/WEB-INF/classes/META-INF -->
        <pathelement location="WebContent/WEB-INF/classes" />
    
        <!-- Location of the .class files -->
        <pathelement location="build/classes" />
    
        <!-- Add the openjpa jars -->
        <fileset dir=".">
            <include name="**/lib/*.jar" />
        </fileset>
    </path>
    <!-- define the openjpac task; this can be done at the top of the -->
    <!-- build.xml file, so it will be available for all targets -->
    <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="jpa.enhancement.classpath" />
    
    <!-- invoke enhancer on all .class files below the model directory -->
    <openjpac>
        <classpath refid="jpa.enhancement.classpath" />
        <fileset dir=".">
            <include name="**/model/*.class" />
        </fileset>
    </openjpac>
    <echo message="Enhancement complete" />
    <!-- ***************************************************************************************************************** -->
    

    On adding this and setting the eclipse to use this build.xml file to create the WAR file. The objects are getting enhanced and I am not getting the "Executing the prepared statement" Trace in my log also it is not executing the extra "Update" statement.