Troy McKinnon wrote:
I have read the documentation, and search the forum and google on this. But I haven't been able to get a handle on it yet. What specific question is how exactly does Hibernate determine if a object is dirty. I notice in the javadoc that there are methods called that compare and old and new value etc. Is there someway to define specific fields and how to determine if they are update... or even better, is there a way to define in the mapping parameter if a field should be used to determine if the object has been updated?
update=false, insert=false is kinda on the same wavelength.. but what I am looking to do is specifically this:
myobj{
id
desc
create_date
update_date
}
I want the update_date to only be modified if I actually do an update.
I was thinking this could be done by always setting it on the object, and then when I update() if any OTHER field was updated it would persist, otherwise the update wouldn't occur.
Alternatively I guess if there was some way to get a list of fields that have changed on an object from session, I could do the check manually and call or not call update based on that.
As it stands it looks like I will have to manually chug thru all the values and compare the new and old values and do the later anyway. I just thought there might be a shorter or 'preferred' way to do this.
Note: the overall effect I am trying to achieve is the following:
I have a CSV file I want to import into my database.
I read the CSV file in manually and map the results into my HibernateObj.
Query query = session.createQuery("select inv.sku from HibernateObj as inv ");
List skus = query.list();
if(skus.contains(item.getSku())){
session.update(item); // NOTE: it is here that I only want to do the update if some of the data has actually changed - excluding the update_date field.
// It appears is always does the update regardless of data actually changing.
}
else{
session.save(item);
}
------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel
