Hi!everyone, I use Hibernate + JBX to wirte a piece of code.Here is my code:
But when running, it is also a OutOfMemory Error. What's your opinion?
Thanks for help!
Joined: Jun 19, 2001
the reason for OutOfMemory is not Hibernate ! its your strange way of splitting the input string...once you enter the do-while loop the index i is never incremented so you are looking at the same character over and over... you will create an huge StringBuffer ...
- your OperateDB class is not Thread Safe (e.g. Transaction is a member variable)
- You should not create the SessionFactory every time the updateData method is called (SessionFactory is an expensive Object to create). Create it once and then just retrieve Session Objects from your SessionFactory every call to updateData
- have a look at saveOrUpdate() method in Session
- if you just want to retrieve one result (if you have the ID) you can use something like that