Jana reddyMadam

Greenhorn
+ Follow
since Oct 07, 2013
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jana reddyMadam

Yes. This concept is called dirty checking.

When you get User object from searchUser method , you have not closed the session , so the session is still active.

User user = userManagementServiceImpl.searchUser("aswin");

With the active session , this object is now persistent object which means , when you commit the transaction, Hibernate tries to check with original instance called Dirty changing, if there is any change this will automatically update the data base ;).

This is a cool feature of hibernate, which inside uses the primary level Cache. Read about primary caching and dirty checking - you will understand more.

Regards
Jana


why are you expecting one row return ? did you insert a row in table, because as per your code, i don't see anything which is really inserting a row in DB table.

just do this, run this query in database directly --> select count(*) from Apps_Responsibilities; --> if it gives Zero , then there is no data.

and then insert a row in db using below script;

insert into Apps_Responsibilities values (1,'Naveen','Module','Service');
commit;


And then run the Hibernate test program now it should give you the rows size as 1. all the best.
I guess that's the correct behavior , because you want to delete the parent object Entity 2 and its primary key is referred in Entity 1 (So it will become Orphan in that case). So to make sure there are no Orphan Object hibernate is deleting child object when you delete parent object.

Note : you can change the Cascade configuration on you ManyToOne Annotation , so that it will not delete the child you intended.

look

@ManyToOne(cascade=CascadeType.ALL) // All means it whatever happens to parent ,child objects also get the same impact. you can change it to below

@ManyToOne(cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH } // but remember Entity 2 primary should not be a foreign key any other table - Data base will not allow to delete this.

Could you please give the configuration you have, so that we can solve this. Let me know if you still want more info.
I guess we can annotate with @Transient on the property getConfirmPassword.. to avoid looking for mapping column.
you may need to Check CascadeType on Relationship.
Thank you Very much Richard. I will read about that.
Hi,

Can we make One-to-One relation as Lazy with JPA and Hibernate instead of always making One to one as Eager fetch.

Please explain.

Thanks
Jana
Hi,

I have a question regarding Dirty checking. When we modify the session Objects and commit the session , Hibernate automatically finds the change and do the update / insert based on the state.
My question here is - how hibernate will find the difference between the data base state and session object while commit the transaction / session. is it hitting DB ? or it actually stores a copy (which we load from DB) and compare with that copy for a change detection ?

if its storing a copy then someone in DB can change the data while transaction is still in progress/ So still dirty checking works fine ?

Thanks
Jana

Thank you!
6 years ago
JSF
That's what my name is - I don't know what is the problem with my name.
6 years ago
JSF
I Would like to know if we can directly extend javax.faces.render.Renderer in such a way that all the components in our application should go through this component (filter) - so that we can modify some components based on some condition.

Ex: we want to apply the Security to existing application - where some of the buttons/links/tables for some users should be enabled/disabled based on some condition (data comes from other service).

So instead of changing all the backing beans .. to render the componnets - I would like to extend the Renderer and make sure all components rendering will happen through this.

Please Suggest.

Thanks
6 years ago
JSF