Java 索引容器Vaadin上的Null指针异常
我正在使用瓦丁的FilterTable插件。 我在下面的代码中得到一个NullPointerException,但找不到原因Java 索引容器Vaadin上的Null指针异常,java,hibernate,vaadin,Java,Hibernate,Vaadin,我正在使用瓦丁的FilterTable插件。 我在下面的代码中得到一个NullPointerException,但找不到原因 cont = new IndexedContainer() cont.addContainerProperty("Patient", String.class, null); cont.addContainerProperty("Date Of Service", String.class,null); cont.addContainerProperty(
cont = new IndexedContainer()
cont.addContainerProperty("Patient", String.class, null);
cont.addContainerProperty("Date Of Service", String.class,null);
cont.addContainerProperty("Provider", String.class, null);
Session session = HibernateUtil.getSessionFactory().openSession();
Iterator<?> iterator = session.createQuery("FROM ConvertVisitToBillingV WHERE ready_for_billing = '0'").list().iterator();
while(iterator.hasNext()){
ConvertVisitToBillingV var = (ConvertVisitToBillingV) iterator.next();
Visits v = (Visits) session.load(Visits.class, var.getVisitId());
Appointments app = (Appointments)session.load(Appointments.class, v.getAppointmentId());
t_id= var.getVisitId();
cont.addItem(t_id);
Resources res = (Resources)session.load(Resources.class, v.getReferredBy());
cont.getContainerProperty(t_id, "Patient").setValue(var.getFirstName() + " " + var.getLastName());
cont.getContainerProperty(t_id, "Date Of Service").setValue(new SimpleDateFormat("MM/dd/yyyy").format(v.getVisitDt()));
cont.getContainerProperty(t_id, "Provider").setValue(res.getResourceFirstName()+" "+res.getResourceLastName());
}
当它执行cont.getContainerPropertyyt_id、property.setValue行时
它偶尔抛出NullPointerException。不明白背后的原因
这背后的原因是什么,任何帮助
谢谢 如果没有更多细节,我会说: v、 某些'v'的getVisitDt为空`` session.loadResources.class,v.getReferredBy;对于某些v返回null,因此res为null。 这可能会解决问题:
cont.getContainerProperty(t_id, "Patient").setValue(var.getFirstName() + " " + var.getLastName());
if(v.getVisitDt()!=null){
cont.getContainerProperty(t_id, "Date Of Service").setValue(new SimpleDateFormat("MM/dd/yyyy").format(v.getVisitDt()));
} else {
cont.getContainerProperty(t_id, "Date Of Service").setValue("?");
}
if(res!=null){
cont.getContainerProperty(t_id, "Provider").setValue(res.getResourceFirstName()+" "+res.getResourceLastName());
else{
cont.getContainerProperty(t_id, "Provider").setValue("?");
}
请把这封信寄出去