OpenJPA executing prepared statement when none exist in the project - openjpa

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?

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.

Related

Ant can't seem to link to groovy properly in NetBeans 8.2

In netBeans 8.2, I'm having an issue reading groovy inside a build.xml file.
I have a project in which I run my script via a build.xml using the build-in Ant 1.9.7.
In it, for my groovy task, I set the following:
<property environment="env" />
<path id="groovy.classpath">
<fileset dir="${env.GROOVY_HOME}/embeddable" />
</path>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="groovy.classpath" />
For environment variable {env.GROOVY_HOME}, I have set the following in windows environment variable:
GROOVY_HOME with the value C:\Program Files (x86)\Groovy\Groovy-2.4.10
Yet I'm still having an error ""Script failed" when reaching the step with Groovy at the following stage in the build.xml file:
<groovy>
def corePlatformList = []
[Groovy code here...]
</groovy>
I know the script is working fine as it does run perfectly in Eclipse and IntelliJ.
It would seem ant can't link with Groovy 2.4.10 for some reason.
I believe that you have some trivial error.
You need to include the library file.
Change from:
<path id="groovy.classpath">
<fileset dir="${env.GROOVY_HOME}/embeddable" />
</path>
To:
<path id="groovy.classpath">
<fileset dir="${env.GROOVY_HOME}/embeddable">
<include name="**/groovy-all-*.jar"/>
</fileset>
</path>
EDIT: based on OP comments
Here is the complete build.xml and I can see it working.
<project name="MyProject" default="runscript" basedir=".">
<path id="groovy.classpath">
<fileset dir="d:/softwares/groovy-2.4.5/embeddable">
<include name="**/groovy-all-*.jar"/>
</fileset>
</path>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="groovy.classpath" />
<target name="runscript"
description="compile the source">
<groovy>
def corePlatformList = [1,2,3,4]
println corePlatformList
</groovy>
</target>
</project>

Sencha CMD Ant integration for custom web application

We are trying to integrate the Sencha CMD to our custom application ant script( build.xml) inorder to do minification of js files. Could you please let us know the steps needs to be followed for minifcation of js files . It could be useful if you could provide sample file to achieve this. We tried the following steps as per the manual to just include the sencha.jar which resulted in error "init-sencha-cmd:
[taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml."
I have added the target "init-sencha-cmd" as dependency to target "build" and a property build.dir (basedir="." configured in the start of xml)
<target name="build" depends="init, dependencies, pre-compile, compile, post-compile,init-sencha-cmd" description="Builds the project." />
<property name="build.dir" location="${basedir}"/>
<target name="init-antcontrib">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${Bundles.WebCharts.lib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
</target>
<target name="init-sencha-cmd" depends="init-antcontrib">
<taskdef resource="com/sencha/ant/antlib.xml" classpath="/Users/hatamm/bin/Sencha/Cmd/5.0.3.324/sencha.jar"/>
</target>

Include/Exclude buildfiles

How do you do this? Given several build files, I only want to include the ones where the target (specified from the command line) exists. Using target::exists in does not seem to work. Thanks.
<target name="*">
<property name="curr.target" value="${target::get-current-target()}"/>
<nant target="${curr.target}">
<buildfiles>
<include name="*.build" if="${target::exists(curr.target)}"/>
<!-- avoid recursive execution of current build file-->
<exclude name="${project::get-buildfile-path()}" />
</buildfiles>
</nant>
</target>
Using robaker's solution, my final build file looks like this. It does not fail anymore if the target is not found in a certain build file (unlike my previous code).
<project>
<include buildfile="A.build"/>
<include buildfile="B.build"/>
<target name="*">
<nant target="${target::get-current-target()}"/>
</target>
</project>
Why not just use the include task to include all your child build scripts instead?

NAnt - Including source files in a csc task outside of the base directory

I am just starting to pick up NAnt as a replacement for MSBuild in our CruiseControl project.
One of the things we do inside a set of projects is link in a single AssemblyInfo.cs file from outside of the project tree to make versioning easier (it lives in a directory above the project folders).
Is there an obvious way of achieving this in the <sources> section of the <csc> task?
From what I can tell, the <sources> section only supports a single <include> element, which must be underneath the basedir of the task.
I suppose another option would be to copy the single AssemblyInfo.cs file as part of the task prior to calling csc, but wondered whether there was a cleaner way of doing this.
You are not limited to a single <include/> in <sources/>. You can reference whatever you want if you don't specift the basedir property of <sources/>:
<csc target="exe" output="HelloWorld.exe" debug="true">
<sources>
<!-- Will use project dir as base dir -->
<include name="**/*.cs" />
<!-- Absolute path -->
<include name="/tmp/42/*.cs" />
<!-- Relative to project dir -->
<include name="../../Shared/*.cs" />
</sources>
<references>
<include name="System.dll" />
<include name="System.Data.dll" />
</references>
</csc>

Can't enhance kodo JPA classes

I am just moving to Kodo JPA version 4.2 and it isn't going smoothly.
when I run my any build script (in eclipse 3.4.1) I get
BUILD FAILED
D:\My Documents\eclipseWorkspaces\cnmp e341\blue ebig\ebig\src\java\build.xml:91: <openjpa-1.1.0-r422266:657916 fatal user error> org.apache.openjpa.util.MetaDataException: MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null). This might mean that no configuration properties were found. Ensure that you have a META-INF/persistence.xml file, that it is available in your classpath, or that the properties file you are using for configuration is available. If you are using Ant, please see the <properties> or <propertiesFile> attributes of the task's nested <config> element. This can also occur if your OpenJPA distribution jars are corrupt, or if your security policy is overly strict.
My build.xml is sitting in my java directory next to my META-INF directory containing my persistence.xml file
here is the snippet from the build.xml
<target name="enhance">
<echo>base dir is ${basedir}</echo>
<!-- define the kodoc task; this can be done at the top of the -->
<!-- build.xml file, so it will be available for all targets -->
<taskdef name="kodoc" classname="kodo.ant.PCEnhancerTask"/>
<!-- invoke enhancer on all .jdo files below the current directory -->
<kodoc>
<fileset dir=".">
<include name="**/jpa/*.java" />
<include name="**/jpa/*.class" />
</fileset>
<classpath>
<pathelement location="${basedir}"/>
</classpath>
</kodoc>
</target>
The entity class files are in the jpa directory. So the directory structure looks like this:
+ top
+ src
+ java
| + com
| + splat
| | + jpa
| | - entity.java
| | + stuff
| - Object.java
| + META-INF
| - persistence.xml
- build.xml
I had thought I had followed the directions in the doc., but clearly I didn't.
Thanks
This problem was fixed by adding config propertiesFile="../../config/ebig.kodo.properties"/>
to the task it now looks like
<kodoc>
<config propertiesFile="../../config/ebig.kodo.properties"/>
<fileset dir=".">
<include name="**/jpa/*.java" />
<include name="**/jpa/*.class" />
</fileset>
<classpath>
<pathelement location="${basedir}"/>
</classpath>
</kodoc>