私はプロジェクトに取り組んでいます。すべて正常に動作していますが、問題はパフォーマンスの問題があることです。コードの応答が遅すぎます。マッピング、 Hibernate 、またはコーディングスタイルの問題であると混乱しています。
すべてのコードはプロパティで機能していますが、何をすべきかわかりませんが、他のプロジェクトのこのプロジェクトでもプロフォーマンスが遅すぎます。ページネーションも追加しましたが、それも機能していません。応答を待つ必要があります。私を助けてください。
これが私のコードです:
プロパティ .java
package org.property.companies.entitybeans;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
@Entity
@Table (name="property")
public class Property {
@Id
@Column (name="property_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int property_id;
@Column (name="p_user_id")
private int p_user_id;
@Column (name="property_type_id")
private int property_type_id;
@Column (name="property_for_id")
private int property_for_id;
@Column (name="builder_id")
private int builder_id;
@Column (name="project_name")
private String project_name;
@Column (name="start_date")
private String start_date;
@Column (name="property_no")
private String property_no;
@Column (name="property_purpose")
private String property_purpose;
@Column (name="property_name_id")
private int property_name_id;
@Column (name="block_building_name")
private String block_building_name;
@Column (name="location_id")
private int location_id;
@Column (name="area")
private String area;
@Column (name="meas")
private String meas;
@Column (name="bed_room")
private String bed_room;
@Column (name="status")
private String status;
@Column (name="price")
private String price;
@Column (name="extra_features")
private String extra_features;
@Column (name="company_id")
private int company_id;
@Column (name="property_date")
private String property_date;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "property_owner", joinColumns = {
@JoinColumn(name = "property_id")}, inverseJoinColumns = {
@JoinColumn(name = "owner_id")})
private PropertyOwner propertyowner;
public Property() { }
.. getter setter ..
}
PropertyOwner.java
package org.property.companies.entitybeans;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
@Entity
@Table (name="property_owner")
public class PropertyOwner {
@Id
@GeneratedValue
@Column (name="owner_id")
private int owner_id;
@Column (name="property_id")
private int property_id;
@Column (name="owner_name")
private String owner_name;
@Column (name="owner_no")
private String owner_no;
@Column (name="owner_email")
private String owner_email;
@Column (name="booking_status")
private String booking_status;
@Column (name="booking_status_date")
private String booking_status_date;
@Column (name="remark")
private String remark;
@Column (name="company_id")
private int company_id;
public PropertyOwner() { }
Logic to get Residentail Property
public List<ResidentialPropertyBean> getResidentialProperty(ResidentialPropertyActions rpa) {
Session session = HibernateSessionFactory.getSessionFactory().openSession();
Transaction transaction = null;
List<ResidentialPropertyBean> residentialpropertylist = null;
List<Property> result = null;
try {
transaction = session.beginTransaction();
int id = Integer.parseInt(rpa.getCompany_id());
Query query = session.createQuery("from Property p where p.company_id = "+id+"");
result = query.list();
residentialpropertylist = new ArrayList<ResidentialPropertyBean>();
for(Iterator it = result.iterator(); it.hasNext();) {
Property p = (Property) it.next();
PropertyOwner po = (PropertyOwner) p.getPropertyowner();
ResidentialPropertyBean rpb = new ResidentialPropertyBean();
rpb.setProperty_id(p.getProperty_id()+"");
rpb.setResidential_property_user(p.getP_user_id()+"");
rpb.setResidential_property_for(p.getProperty_for_id()+"");
rpb.setResidential_property_type(p.getProperty_type_id()+"");
rpb.setResidential_property_builder_name(p.getBuilder_id()+"");
rpb.setResidentail_property_project_name(p.getProject_name());
rpb.setResidentail_property_start_date(p.getStart_date());
rpb.setResidential_property_no(p.getProperty_no());
rpb.setResidential_property_name(p.getProperty_name_id()+"");
rpb.setResidential_property_block_building_name(p.getBlock_building_name());
rpb.setResidential_property_location(p.getLocation_id()+"");
rpb.setResidential_property_area(p.getArea());
rpb.setResidential_property_meas(p.getMeas());
rpb.setResidential_property_bed_room(p.getBed_room());
rpb.setResidential_property_status(p.getStatus());
rpb.setResidential_property_price(p.getPrice());
rpb.setResidential_property_extra_features(p.getExtra_features());
rpb.setProperty_purpose(p.getProperty_purpose());
rpb.setOwner_id(po.getOwner_id()+"");
rpb.setResidential_property_owner_name(po.getOwner_name());
rpb.setResidential_property_owner_phone(po.getOwner_no());
rpb.setResidential_property_owner_email(po.getOwner_email());
rpb.setResidential_property_booking_status(po.getBooking_status());
rpb.setResidential_property_booking_status_date(po.getBooking_status_date());
rpb.setResidential_property_remark(po.getRemark());
residentialpropertylist.add(rpb);
}
session.getTransaction().commit();
}
catch (Exception e) {
e.printStackTrace();
session.getTransaction().rollback();
session.close();
} finally {
session.close();
}
return residentialpropertylist;
}
ResidentialPropertyBean.java
package org.property.companies.beans;
public class ResidentialPropertyBean {
private String property_id;
private String residential_property_user;
private String residential_property_type;
private String residential_property_for;
private String residential_property_builder_name;
private String residentail_property_project_name;
private String residentail_property_start_date;
private String residential_property_no;
private String residential_property_name;
private String property_purpose;
private String residential_property_block_building_name;
private String residential_property_location;
private String residential_property_area;
private String residential_property_meas;
private String residential_property_bed_room;
private String residential_property_status;
private String residential_property_price;
private String residential_property_price_meas;
private String residential_property_extra_features;
private String owner_id;
private String residential_property_owner_name;
private String residential_property_owner_phone;
private String residential_property_owner_email;
private String residential_property_booking_status;
private String residential_property_booking_status_date;
private String residential_property_remark;
struts.xml
<action name="getResidentialProperty" class="org.property.companies.actions.ResidentialPropertyActions" method="getResidentialProperty" >
<interceptor-ref name="companyStack" />
<result name="success" type="json" />
<result name="login" type="redirectAction">index</result>
</action>
JS ファイル
$(document).ready(function() {
var residential_property_list = null;
var company_id = $("input[name='company_id']").val();
dataTransation("getResidentialProperty.action",{token : "Verified", company_id : company_id},"GetResidentialProperty","json");
function dataTransation(request,data,operation,type) {
switch(type) {
case "default" :
$.ajax({
type : "POST",
data : data,
url : request,
success : function(response) {
}
});
break;
case "json" :
$.ajax({
type : "POST",
data : data,
url : request,
dataType : "json",
success : function(response) {
if(operation == "GetResidentialProperty") {
initializeResidentialPropertyList(response);
}
}
});
break;
}
}
function initializeResidentialPropertyList(response) {
residential_property_list = response;
populateProperty();
}
function populateProperty() {
$("#property_container").html("");
$(residential_property_list.residentialproperty).each(function(index,data) {
$("#property_container").append("Fill Property Info");
});
}
});