我创建了一个 Web 应用程序来使用Spring Roo和Gvnix工具管理兽医诊所。
我创建了包含兽医、主人、宠物、约会表的数据库,所有这些表都与1 对多相关,除了与多对多相关的表治疗和药物之外,上面的这 2 个表包括一个中间表,称为 _treatment_med_ 用于它们之间进行交互,使用数据库管理器MySQL 工作台和MYSQL Server ,一切正常,从我的 web 应用程序表单创建、更新和删除 所有者、宠物、兽医、约会、药物,但是当我尝试创建超过 2 条关于表格治疗的记录时,通过治疗标签jspx在与表格相关的药物中进行多项选择。
<field:select field="Med" id="c_com_clinicaveterinaria_dam_domain_Tratamiento_Med" itemValue="id" items="${medicamentoses}" multiple="true" path="/medicamentoses" z="+hr+pOBWxfr2whYp+joa+OMxAHk="/>
该应用程序给了我一个没有详细信息的错误,因为我完全放弃了
我从带有Java (TM) 平台 SE 二进制名称(java.exe)的 Windows 任务管理器中看到进程飙升至+1,800 KB(私人工作空间)以上,这使得 Web 应用程序下降。
AspectJ 类中这部分代码中的问题是 Gvnix 与名称的持久性。
特权方面 TratamientoBatchService_Roo_GvNIXJpaBatch {
我认为错误就在这里。
@Transactional
public void TratamientoBatchService.create(List<Tratamiento> tratamientoes) {
for( Tratamiento tratamiento : tratamientoes) {
tratamiento.persist();
}
}
这是向我显示 IntelliJ IDE 控制台的错误:
Stacktrace:] with root cause java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:137)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:121)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:421)
at java.lang.StringBuffer.append(StringBuffer.java:272)
at org.apache.commons.lang3.builder.ToStringStyle.appendFieldSeparator(ToStringStyle.java:1503)
at org.apache.commons.lang3.builder.ToStringStyle.appendFieldEnd(ToStringStyle.java:1526)
at org.apache.commons.lang3.builder.ToStringStyle.append(ToStringStyle.java:439)
at org.apache.commons.lang3.builder.ToStringBuilder.append(ToStringBuilder.java:848)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.appendFieldsIn(ReflectionToStringBuilder.java:522)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:683)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:282)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:145)
at com.clinicaveterinaria.dam.domain.Citas_Roo_ToString.ajc$interMethod$com_clinicaveterinaria_dam_domain_Citas_Roo_ToString$com_clinicaveterinaria_dam_domain_Citas$toString(Citas_Roo_ToString.aj:13)
at com.clinicaveterinaria.dam.domain.Citas.toString(Citas.java:1)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuffer.append(StringBuffer.java:265)
at org.apache.commons.lang3.builder.ToStringStyle.appendDetail(ToStringStyle.java:586)
at org.apache.commons.lang3.builder.ToStringStyle.appendInternal(ToStringStyle.java:550)
at org.apache.commons.lang3.builder.ToStringStyle.append(ToStringStyle.java:436)
at org.apache.commons.lang3.builder.ToStringBuilder.append(ToStringBuilder.java:848)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.appendFieldsIn(ReflectionToStringBuilder.java:522)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:683)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:282)
at org.apache.commons.lang3.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:145)
at com.clinicaveterinaria.dam.domain.Tratamiento_Roo_ToString.ajc$interMethod$com_clinicaveterinaria_dam_domain_Tratamiento_Roo_ToString$com_clinicaveterinaria_dam_domain_Tratamiento$toString(Tratamiento_Roo_ToString.aj:13)
at com.clinicaveterinaria.dam.domain.Tratamiento.toString(Tratamiento.java:1)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:317)
at java.lang.String.valueOf(String.java:2994)
我尝试从 IDE IntelliJ IDEA 配置 Maven 服务器,以通过“-Xmx512m - XX:MaxPermSize = 128 m”增加可承受的内存量,但问题无法解决。
这是我的 Java 类:Tratamiento.java
package com.clinicaveterinaria.dam.domain;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@RooJavaBean
@RooToString
@RooJpaActiveRecord
public class Tratamiento {
/**
*/
@NotNull
@Size(min = 5, max = 100)
private String Codigo;
/**
*/
@Size(min = 3, max = 250)
private String AnalisisClinicos;
/**
*/
@Size(min = 3, max = 250)
private String Medicamentos;
/**
*/
private double Coste;
/**
*/
@Size(min = 3, max = 250)
private String Diagnostico;
/**
*/
@Size(min = 3, max = 250)
private String MotivoIngreso;
/**
*/
@NotNull
@Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(style = "M-")
private Date FechaComienzoTratamiento;
/**
*/
@Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(style = "M-")
private Date FechaFinTratamiento;
/**
*/
@ManyToOne
private Citas citas;
/**
*/
@ManyToMany(cascade = CascadeType.ALL)
private Set<Medicamentos> Med = new HashSet<Medicamentos>();
public static List<Tratamiento> findTratamientoXDueño(int idUsr) {
if (idUsr <= 0 /*mas comprobaciones*/) return null;
Query query = entityManager().createNativeQuery(
" SELECT t.* FROM tratamiento t " +
" INNER JOIN citas c ON c.id = t.citas " +
" INNER JOIN mascota m ON m.id = c.mascotas " +
" WHERE m.duenio = (:idUsr)"
, Tratamiento.class).setParameter("idUsr", idUsr);
return query.getResultList();
}
public static List<Tratamiento> findTratamientoXVeterinario(int idUsr) {
if (idUsr <= 0 /*mas comprobaciones*/) return null;
Query query = entityManager().createNativeQuery(
" SELECT t.* FROM tratamiento t " +
" INNER JOIN citas c ON c.id = t.citas " +
" WHERE c.veterinarios = (:idUsr)"
, Tratamiento.class).setParameter("idUsr", idUsr);
return query.getResultList();
}
}
谢谢你的帮助,我正在做最后的课程项目。
我正在使用 MVC (模型-视图-控制器)。
抱歉,我的英语很不好。