Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes Hibernate query error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate query error" Watch "Hibernate query error" New topic
Author

Hibernate query error

Sumer Selvaraj
Greenhorn

Joined: May 02, 2013
Posts: 15
Hi,

I'm studying Hibernate by my self. I've created a query to check the username & password which are passed through the front end.



This works. But the issue is when I make a change in the database, the results shows the old information where it should show the new information. Further I need to redeploy the project or restart the server in order to show the new data.

Can anyone help me on this?
Niraj Jha
Ranch Hand

Joined: Feb 20, 2013
Posts: 63

When do you make change in the database?
If you are doing same time while application is running then how it will reflect the changes in data from back end as it has loaded in the session earlier.
Sumit Bisht
Ranch Hand

Joined: Jul 02, 2008
Posts: 329

You can do the changes, but ensure that you update this information through hibernate itself.
That way your entities and their associated cache will be updated first and the changes persisted to the database.
Sumer Selvaraj
Greenhorn

Joined: May 02, 2013
Posts: 15
Niraj Jha wrote:When do you make change in the database?
If you are doing same time while application is running then how it will reflect the changes in data from back end as it has loaded in the session earlier.


Ya I've changed the value while the programme is running. As per you, I've cleared the session but it didn't work. The new codes are

testHibernate Class



JSP page
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

If you put java code into jsp page then it is wrong old way. Now it is not good practice. Your jsp page should not contain java code!

You need to understand that entity has three states - transient, persistent and detached. Changes made to entity in persistent state are stored into database when your transaction is committed. I recommend you to pass these free tutorials on hibernate


True person is moral, false is right!
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

To understand better hibernate objects state you MUST read relevant chapter in hibernate doc
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate query error