When I run a query with hibernate I get this log:
Code:
[DEBUG] [13:17:37,207] [cappman] Search started
[DEBUG] [13:17:37,222] [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[DEBUG] [13:17:37,222] [SQL] select count(*) as y0_ from "TASKLET" this_ inner join "JOB" job1_ on this_.JOB_ID=job1_.id where this_.TIME_STAMP>=? and this_.TIME_STAMP<=?
[DEBUG] [13:17:37,222] [SQL] select count(*) as y0_ from "TASKLET" this_ inner join "JOB" job1_ on this_.JOB_ID=job1_.id where this_.TIME_STAMP>=? and this_.TIME_STAMP<=?
[DEBUG] [13:17:55,847] [AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
[DEBUG] [13:17:55,847] [AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
[DEBUG] [13:17:55,847] [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[DEBUG] [13:17:55,847] [StatefulPersistenceContext] initializing non-lazy collections
[DEBUG] [13:17:55,863] [cappman] Rowcount in 18 s
How come it takes about 18 seconds to complete when it takes about 2 ms to complete when run in directly against my Oracle database?
Why is there two log statements for the query? Bug?
I probably should provide some more info but I'm not sure what. If you need more, ask for it and I will try to answer.
Hibernate config:
Code:
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Connection Pooling -->
<!-- select count(*) from gv$session where username='CMAN_WEB_DBO'; -->
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.max_size">40</property>
<property name="hibernate.c3p0.timeout">7200</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.max_fetch_depth">1</property>
<property name="hibernate.default_entity_mode">pojo</property>
<property name="hibernate.jdbc.wrap_result_sets">false</property>
<property name="hibernate.dbcp.ps.maxIdle">0</property>
<property name="hibernate.statement_cache.size">0</property>
<property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.default_batch_fetch_size">8</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.format_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@(**)</property>
<property name="connection.username">**_dbo</property>
<property name="connection.password">**</property>
<mapping class="cappman.common.dto.UserDTO"/>
<mapping class="cappman.common.dto.RoleDTO"/>
<mapping class="cappman.common.dto.TaskDTO"/>
<mapping class="cappman.common.dto.TaskletDTO"/>
<mapping class="cappman.common.dto.JobDTO"/>
<mapping class="cappman.common.dto.JobActionDTO"/>
<mapping class="cappman.common.dto.JobFileDTO"/>
<mapping class="cappman.common.dto.FileDTO"/>
<mapping class="cappman.common.dto.FamilyDTO"/>
<mapping class="cappman.common.dto.FamilyProgramDTO"/>
<mapping class="cappman.common.dto.ProgramDTO"/>
<mapping class="cappman.common.dto.ProgramFileDTO"/>
<mapping class="cappman.common.dto.OrderErrorDTO"/>
<mapping class="cappman.common.dto.QuotationErrorDTO"/>
<mapping class="cappman.common.dto.ErrorHistoryDTO"/>
</session-factory>
</hibernate-configuration>
Tasklet POJO:
Code:
/*
* TaskletDTO.java
*
* Created on den 1 juni 2007, 16:08
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package cappman.common.dto;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.SequenceGenerator;
import javax.persistence.Transient;
/**
* Data Transport Object for a tasklet
* @author mats.l.nilsson@sandvik.com
*/
@Entity
@org.hibernate.annotations.Entity (dynamicUpdate=true)
@SequenceGenerator(name = "hib_seq", sequenceName = "HIBERNATE_SEQUENCE")
@Table(name = "`TASKLET`")
public class TaskletDTO extends AssignmentDTO {
private String _workerName;
@Column(name = "WORKER_NAME")
public String getWorkerName() {
return _workerName;
}
public void setWorkerName(String workerName) {
this._workerName = workerName;
}
@Transient
public String getWorkerHost(){
String host = _workerName;
if (_workerName!=null){
if (_workerName.indexOf("/")>0){
host = _workerName.substring(0, _workerName.indexOf("/"));
}
if (host.indexOf(".")>0){
host = host.substring(0, host.indexOf("."));
}
}
return host;
}
@Transient
public String getWorkerIP(){
String ip = _workerName;
if (_workerName!=null){
if (_workerName.indexOf("/")>0){
ip = _workerName.substring(_workerName.indexOf("/"),_workerName.length());
} else {
ip = _workerName;
}
}
return ip;
}
private String _name;
@Column(name = "NAME")
public String getName() {
return _name;
}
public void setName(String name) {
this._name = name;
}
private String _description;
@Column(name = "DESCRIPTION")
public String getDescription() {
return _description;
}
public void setDescription(String description) {
this._description = description;
}
private List<FileDTO> _files = new ArrayList<FileDTO>();
@OneToMany(cascade = CascadeType.REFRESH, fetch=FetchType.LAZY)
@JoinTable(name = "`TASKLET_CAPP_FILE`", joinColumns = {@JoinColumn(name = "TASKLET_ID", referencedColumnName = "ID")}, inverseJoinColumns = {@JoinColumn(name = "CAPP_FILE_ID", referencedColumnName = "ID")})
public List<FileDTO> getFiles() {
return _files;
}
public void setFiles(List<FileDTO> files) {
_files = files;
}
private TaskDTO _task = new TaskDTO();
@ManyToOne(cascade = CascadeType.REFRESH, fetch=FetchType.LAZY)
@JoinColumn(name = "TASK_ID", referencedColumnName = "ID")
public TaskDTO getTask() {
return _task;
}
public void setTask(TaskDTO task) {
this._task = task;
}
private JobDTO _job = new JobDTO();
@ManyToOne(cascade = CascadeType.REFRESH, fetch=FetchType.LAZY)
@JoinColumn(name = "JOB_ID", referencedColumnName = "ID")
public JobDTO getJob() {
return _job;
}
public void setJob(JobDTO job) {
this._job = job;
}
@Transient
public FileDTO getLogFile() {
FileDTO logFile = null;
for (FileDTO file : getFiles()) {
if (file.getKey().equalsIgnoreCase("logfile")){
logFile = file;
break;
}
}
return logFile;
}
}