I'm using annotations and I'm getting this strange error, when triggering following function:
Code:
Session session = HibernateCoreUtil.getSession();
String reportFormId = request.getParameter("id");
if (reportFormId==null && !reportFormId.equals(""))
throw new RuntimeException("Report form id is mandatory");
ReportForm report = (ReportForm)session.load(
ReportForm.class,
Long.valueOf(reportFormId)
);
String json = "{success:true, data:" + JSONHelper.getHelper().getJSONObject(report).toString() + "}";
session.close();
PrintWriter writer = response.getWriter();
writer.write(json);
writer.close();
The class looks like this:
Code:
@Entity
@Table(name="SysReportForm")
@javax.persistence.NamedQueries
({
@NamedQuery(name="sys.allReportForms", query="select o from ReportForm o"),
@NamedQuery(name="sys.getReportFormById", query="select o from ReportForm o where o.id = :id"),
@NamedQuery(name="sys.getReportFormByNameSymbol", query="select o from ReportForm o where o.nameSymbol = :nameSymbol"),
})
public class ReportForm {
@Id
@GeneratedValue
private Long id;
@Column(name = "nameSymbol", length=30, nullable=false, unique=true)
private String nameSymbol;
@Column(name = "description", length=30, nullable=false)
private String description;
@ManyToOne
@JoinColumn(name="moduleId", nullable=false)
private Module module;
@ManyToMany(targetEntity=ReportCategory.class,cascade={CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable(name="SysReportFormReportCategory",joinColumns=@JoinColumn(name="reportFormId"),inverseJoinColumns=@JoinColumn(name="reportCategoryId"))
private List<ReportCategory> categories = new ArrayList<ReportCategory>();
Why is this error happening I'm not updating anything?
Any help appreciated.