2013年11月17日星期日

hibernate query the data updated, seeking a master to a solution

Is a simple query function to find out later in the page display no problem, but look at the background of the log , the last one is the updated data in the database updated, the second query when the data is not right , seeking solutions to master ah ~ ~ ~ ~ ~ ~
------ Solution --------------------------------- -----------
debug ah , look at where code is executed when the update step , hibernate configuration show_sql set to true
------ Solution ------ --------------------------------------
there is a solution can be found .
In the query , use evict objects from the hibernate manual controls allow
------ Solution ----------------------- ---------------------
Hibernate get or load method should not automatically perform update operations ah
Is not you write the code update . . ?

------ Solution ------------------------------------ --------
are not updated automatically update how sure are you code problems
------ Solution -------------- ------------------------------
query when you are in what is called the updated code where it ~ ~

best in the query is not open transaction
------ Solution ---------------------------- ----------------
I encountered a similar problem I hope you can help
java bean get methods do not do any operations, such as
String getName () {
return name == null? "": name;
}
with pure javabean
String getName () {
return name;
}
as null and " " is not the same
------ Solution ----------------------- ---------------------
seemingly landlord hibernate persistent object of understanding is not enough.

For example, you inquiries XX xx = (XX) session.get (XX.class, id);
this time xx for persistent objects , this time when you xx.setXXX (XXX); This time , xx object has changed

When you close HibernateSessionFactory when you change the contents of the data inside the database and synchronize ~
------ Solution --------------- -----------------------------
session.createQuery If you just do try to use this query
------ For reference only ---------------------------------------
No update, I found online because the object . get () after , it would be more original data, if not the same will be updated .
------ For reference only -------------------------------------- -
query method where I really did not write update ah, check it several times
------ For reference only ------------------ ---------------------
evict manual ? ? ? How else
------ For reference only ----------------------------------- ----
my query update method really did not call any method to check a lot of times , no one encountered this problem? ?
------ For reference only -------------------------------------- -
I did not do what ah , that is defining the fields , use the shortcut key to generate the get and set methods , so no action ah , but I use the hibernate configuration file and the spring configuration file , there will affect you
------ For reference only --------------------------------------- < br> but I use the object only projects where an ordinary object , not the session ah
------ For reference only ------------------- --------------------
there was a problem just like you , I would have been here is the data in the database after each query that record was empty , depressed dead, seek expert advice
------ For reference only ---------------------------- -----------
today, there have been , for a long time found a Hibernate management entity class has a property of Set methods this. been removed , plus all the normal

没有评论:

发表评论