我在使用以下结构时遇到性能问题,目前我必须上课
1.Product 2.Category
1个产品有很多类别
2类有很多产品
1个类别有很多类别(自我)
产品类--->
<div class="form-file-upload">
<button type="button" class="close"></button>
</div>
}
类别类----&gt;
@Entity
@Table(name = ProductService.TABLE_NAME)
public class ProductService {
public static final String TABLE_NAME = "BB_Product_Service";
public static final String TABLE_NAME_PROD_SUB_CAT = "BB_Product_Sub_category";
public static final String COLUMN_PRODUCT_ID = "pk_product_id";
public static final String COLUMN_PRODUCT_NAME = "product_name";
public static final String COLUMN_PRODUCT_DESCRIPTION = "product_description";
public static final String COLUMN_PRODUCT_NOTE = "product_note";
public static final String COLUMN_PRODUCT_PRICE = "product_price";
public static final String COLUMN_PRODUCT_MAINTENANCE = "product_maintenance";
public static final String COLUMN_PRODUCT_EXPENSES = "product_expenses";
public static final String COLUMN_STATUS = "status";
public static final String USER_ADDED_BY_FOREIGN_KEY = "fk_added_by";
public static final String COLUMN_USER_ADDED_ON = "added_on";
public static final String USER_MODIFIED_BY_FOREIGN_KEY = "fk_modified_by";
public static final String COLUMN_USER_MODIFIED_ON = "modified_on";
public static final String TABLE_PRODUCT_CATEGORY = "BB_Product_category";
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = COLUMN_PRODUCT_ID)
private int productId;
@Column(name = COLUMN_PRODUCT_NAME, columnDefinition = "VARCHAR(255)", nullable = false)
private String productName;
@Column(name = COLUMN_PRODUCT_DESCRIPTION, columnDefinition = "VARCHAR(500)", nullable = true)
private String productDescription;
@Column(name = COLUMN_PRODUCT_NOTE, columnDefinition = "VARCHAR(255)", nullable = true)
private String productNote;
@Column(name = COLUMN_PRODUCT_PRICE, columnDefinition = "INT(10)", nullable = true)
private int productPrice;
@Column(name = COLUMN_PRODUCT_MAINTENANCE, columnDefinition = "INT(10)", nullable = true)
private int productMaintenance;
@Column(name = COLUMN_STATUS, columnDefinition = "TINYINT(1) DEFAULT 1", nullable = false)
private int status;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = COLUMN_USER_ADDED_ON, columnDefinition = "DATETIME", nullable = false)
private Date userAddedOn;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = COLUMN_USER_MODIFIED_ON, columnDefinition = "DATETIME", nullable = true)
private Date userModifiedOn;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = TABLE_PRODUCT_CATEGORY, joinColumns = @JoinColumn(name = COLUMN_PRODUCT_ID), inverseJoinColumns = @JoinColumn(name = Category.COLUMN_CATEGORY_ID))
@Where(clause="status=1")
private List<Category> categories;
//Setter an Getter
从上面的结构一切都运行良好但仍然遇到性能问题,如何才能提高性能我可以将manyTomany注释放在类别实体中吗?请帮帮我.....提前谢谢