我正在尝试使用以下代码保存qcomputer的linkedlist:
public void saveOrUpdateAll(Collection list) {
final Session ses = getTxManager().getSessionFactory().getCurrentSession();
list.stream().forEach((object) -> {
ses.saveOrUpdate(object);
});
ses.flush();
}
如果qcomputer中的变量planservices(表services\ to\ u ip)不为空,则获取异常,否则数据存储在表ip\ to\ u单元中:
[IllegalArgumentException occurred calling getter of ru.apertum.qsystem.server.model.QComputer.ip]
(org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of ru.apertum.qsystem.server.model.QComputer.ip)
SQL:
at ru.apertum.qsystem.client.forms.FAdmin.saveConfiguration(FAdmin.java:1910)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jdesktop.application.ApplicationAction.noProxyActionPerformed(ApplicationAction.java:662)
at org.jdesktop.application.ApplicationAction.actionPerformed(ApplicationAction.java:698)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.Event
运行(eventdispatchthread.run)。java:82)
qcomputer.java(mysql中的ip\到\单位表):
public QComputer() { }
private Long id;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
private String ip;
public void setIp(String ip) {
this.ip = ip;
}
@Column(name = "ip")
public String getIp() {
return ip;
}
private Integer unitId;
public void setUnitId(Integer unitId) {
this.unitId = unitId;
}
@Column(name = "unit_id")
public Integer getUnitId() {
return unitId;
}
private String name;
public void setName(String name) {
this.name = name;
}
@Column(name = "name")
public String getName() {
return name;
}
@Column(name = "deleted")
@Temporal(javax.persistence.TemporalType.DATE)
private Date deleted;
public Date getDeleted() {
return deleted;
}
public void setDeleted(Date deleted) {
this.deleted = deleted;
}
private List<QPlanService> planServices = new ArrayList<>();
public void setPlanServices(List<QPlanService> planServices) {
this.planServices = planServices;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
@JoinColumn(name = "ip", insertable = true, nullable = false, updatable = true, referencedColumnName="ip")
@Fetch(FetchMode.SELECT)
public List<QPlanService> getPlanServices() {
return planServices;
}
qplanservice.java(mysql中的服务到ip表):
public QPlanService() {}
private Long id;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
private QService service;
@OneToOne(targetEntity = QService.class)
public QService getService() {
return service;
}
public void setService(QService service) {
this.service = service;
}
private String ip;
@Column(name = "ip", insertable = false, updatable = false)
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
为什么会出现这种错误?我认为解决这个问题的办法很简单,但我不明白原因。任何帮助都是好的。
暂无答案!
目前还没有任何答案,快来回答吧!