here is my code(web service creating by axis2 ,generated by eclipse jboss tools)
public PlayerCalendar[] getCalendarByUseridArr(String userid){
au.backpack.Calendar cal=new au.backpack.Calendar();
PlayerCalendar[] arr=new PlayerCalendar[cal.getCalendarByUserid(userid).length];
arr=cal.getCalendarByUserid(userid);//get the hibernate dao result
for(int i=0;i<arr.length;i++){
//i want to create new Url value
String url=arr[i].getUrl()+"?eventid="+arr[i].getEventid();
arr[i].setUrl(url);
}
return arr;
}
and here is my dao function
public PlayerCalendar[] getCalendarByUserid(String userid){
Session session = HibernateUtil.currentSession();
Transaction tx = null;
tx = session.beginTransaction();
List<PlayerCalendar> list =session.createQuery("from PlayerCalendar where userid='"+userid+"'").list();
int listlen=1;
if(list.size()>1)
listlen=list.size();
PlayerCalendar [] sr = new PlayerCalendar[listlen];
return list.toArray(sr);
}
it's work in my xml web service page (Axis2),
THE URL value like :
user_calendarEvent.jsp?eventid=1
but when i refresh the page approximately 5~9 times
it starts to append more "?eventid=1" :
user_calendarEvent.jsp?eventid=1?eventid=1
and after starts to append, every times i refresh it , it always append "eventid=1"
user_calendarEvent.jsp?eventid=1?eventid=1?eventid=1
but the true value just
user_calendarEvent.jsp?eventid=1
where it wrong ?
thanks~
You don't close Hibernate Session, so your PlayerCalendar
instances remain attached to session, then you modify their url
property by calling
String url=arr[i].getUrl()+"?eventid="+arr[i].getEventid();
arr[i].setUrl(url);
so hibernate updates the entity on each request (and concats ?eventid=...
to it).
So it is normal to have a URL with multiple ?eventId=...
s.