g wildin

Greenhorn
+ Follow
since Jun 26, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by g wildin

Maybeit appears because you are trying to save a String which does not have a mapping so Hibernate doesn't know how to save it.
I am a novice,but maybe the evict() method wouldn't be easy for your code. You might try the Session.clear() method mentioned below. I'm anxious to hear if it works for you. Here's what I found about this:

Any time an object passes through the Session instance, it's added to the Session�s cache. By passes through, we're referring to saving or retrieving the object to and from the database. To see whether an object is contained in the cache, call the Session.contains()method. Objects can be evicted from the cache by calling the Session.evict() method. Let's revisit the previous code, this time evicting the first Event instance:
Session session =factory.openSession();
Event firstEvent =(Event)session.load(Event.class,myEventId);
//...perform some operation on firstEvent
if (session.contains(firstEvent)){
session.evict(firstEvent);
}
Event secondEvent =new Event();
secondEvent.setId(myEventId);
session.save(secondEvent);
The code first opens the Session instance and loads an Event instance with a given ID. Next, it determines whether the object is contained in the Session cache and evicts the object if necessary. The code then creates a second Event instance with the same ID and successfully saves the second Event instance.
If you simply want to clear all the objects from the Session cache, you can call the aptly named Session.clear()method.

Allow me to guess (disclaimer: I just took a hibernate class, but have no experience with it...). Maybe you are getting the detached object - that is why it is the old data. I think you can use if(session.contains(obj)) { session.evict(obj); } to remove it. Hope this helps.