jpa display actual sql query for only one Query - openjpa

I couldn't use
SQL=TRACE
since, there so many queries executed each second, but wish to see the same result for only one Query.
Is there anyway to get this.
Thanks.

No, there is no way to do this via configuration. Perhaps you could write a custom JDBCListener and try to log only the SQL you care about? Good luck!

Related

Read data in batch

I want to read data from db using spring jdbctemplate in batches of specific size. I found batchupdate to update table data, but couldn't find any select in batches. Can someone please help me here?
If I understand right what you are looking for then
Use setFetchSize method to set the fetch size. This would select only specific size.
for writing , we call it batch. For reading, we call it paging. in fact, you can implement by yourself. Here is an example.

DB2 System Tables Logs?

I'm using DB2 LUW. I'm working on looking at how often data is being changed or added into our database, and I was curious if there was a system table that I might be able to find this information?
It depends a bit on what you mean. You will for example find the #commit and #rollback in sysibmadm.snapdb, #rows_written per table can be found in sysibmadm.snaptab. If you take snapshots from those on a regular basis you get an idea on how often data is updated. Was that what you had in mind, or is it something else you are looking for?

Increase security of DB INSERT

Currently, I have a PostGIS DB, and I have the basics working. However, I am inserting directly into the database using pg_query. I have been recommended to use pg_query_params to help prevent against SQL injections, but am unsure how to implement this. Below is a cut-down example of my current insert statement for a site location. How would I, for example, utilise pg_query_params with this example? I know I will have to implement further security, but it is a starting point.
EDIT: I was going to use the drupal form API but it gave me headaches. I realize that would do a lot of this stuff automatically.
$sql = "INSERT INTO sites_tbl (river_id ,sitename ,the_geom) VALUES ('$_POST[river_id]','$_POST[sitename]',st_geomfromtext('POINT($geomstring)',27700))";
$result = pg_query($sql);
Because you are using strings rather than parameters, your example is vulnerable to SQL injection. It's best to avoid pg_ functions. In your case there are two things you need to take into account:
Learn the Drupal API (considering you are using Drupal this would be the best for code consistency
or
Use stored procedures
Use a library like PDO or pg_query_params which takes care of parameterized queries
Normally you use stored procedures in addition to PDO, unfortunately sometimes this is not manageable because you have too much code. My advice is to use as much stored procedures as possible.

How to perform full text search on a gin postgres index in doctrine 2.2?

Is there a simple way of doing this in doctrine, or am I going to have to do a native sql query? If someone could point me in the right direction, it would be appreciated.
Quick answer is, no. There is not a "simple way" of doing this.
You need to use Doctrine Native SQL which can be found here. This will allow you to map the results into usable entities like you're used to while using database specific things.
You could also use a DQL user defined function, described here. This is probably the "correct" way.

EntityManager's named query are slow where as JPAEntityManager's Expression query are faster

I am using Weblogic 10.3 and EJB3 with TopLinks(EclipseLinks) JPA implementation. I am facing an issue with my named queries, which are performing slow. However If I use EclipseLinks JPAEntityManager's Expression query to achieve same, its faster. I am not able to understand why my standard JPA named queries are slow. Has anyone faced similiar issue or Can someone explain the root cause of this issue.
Am I missing any basic tunning or parameter???
That is very odd. Named queries should be in general faster as they are parsed once.
What is the specific query and its SQL? Are you comparing it to the same Expression query, or something different, which is its SQL?
Try enabling the EclipseLink PerformanceProfiler on the queries, or try using a Java profiler such as JProfiler.