Hi,
Here's the difference. between. update() and merge() in hibernate
Update():- if you are sure that the session does not contains an already persistent instance with the same identifier then use update to save the data in hibernate
Merge():-if you want to save your modificatiions at any time with out knowing abot the state of an session then use merge() in hibernate.
Cheers,
Happy Coding :)
Showing posts with label hibernate. Show all posts
Showing posts with label hibernate. Show all posts
Saturday, December 18, 2010
Monday, October 25, 2010
Ibatis Vs Hibernate
I have using Hibernate and Ibatis for a year now, and I find myself switching twice from Hibernate to iBatis, not because one is better than the other, it's because of what preperations each framework needs.
In hibernate you need to have a proper plan to design your database, the database is controled by the hibernate roles and you spend time try to fullfill these rules, and if you go the other way (database->OO) it's harder.
With Ibatis I find myself getting the Job done faster, I create any POJO any set of tables, and I link them, much flixability in that field, but little extra work, building Queries and managing Maps (but hay, you spend time with hibernate maps too).
Both are good in a way with iBatis you finish the Job faster, which I like, but you won't have the big tools that hibernate provide, nor iBatis will provide the facility to generate the sql for you.
With Hibernate3 it maybe a different story, since allot of what can stop you in H2 and make you think of iBatis is there in H3, still iBatis is growing up.
ibatis:
-Simpler
-faster development time
-flixable
-Much smaller in package size
hibernate:
-generate SQL for you which means you don't spend time on SQL
-provide much more advance cache
-scalable
For now I use iBatis, but keeping my eyes on Hibernate3, by the way, you can always use iBatis to have a fast start, and move to hibernate on late stages if you want, iBatis provide special DAO framework for that.
Learn both, use both, and if you don't have time learn and use iBatis, you won't regret it.
In hibernate you need to have a proper plan to design your database, the database is controled by the hibernate roles and you spend time try to fullfill these rules, and if you go the other way (database->OO) it's harder.
With Ibatis I find myself getting the Job done faster, I create any POJO any set of tables, and I link them, much flixability in that field, but little extra work, building Queries and managing Maps (but hay, you spend time with hibernate maps too).
Both are good in a way with iBatis you finish the Job faster, which I like, but you won't have the big tools that hibernate provide, nor iBatis will provide the facility to generate the sql for you.
With Hibernate3 it maybe a different story, since allot of what can stop you in H2 and make you think of iBatis is there in H3, still iBatis is growing up.
ibatis:
-Simpler
-faster development time
-flixable
-Much smaller in package size
hibernate:
-generate SQL for you which means you don't spend time on SQL
-provide much more advance cache
-scalable
For now I use iBatis, but keeping my eyes on Hibernate3, by the way, you can always use iBatis to have a fast start, and move to hibernate on late stages if you want, iBatis provide special DAO framework for that.
Learn both, use both, and if you don't have time learn and use iBatis, you won't regret it.
Labels:
hibernate,
hibernate vs ibatis,
ibatis,
Ibatis Vs Hibernate
Friday, May 1, 2009
Hibernate Statistics
This is pretty cool. When you're experimenting with different mapping strategies, you can get Hibernate to provide you with stats for the number of queries, fetches, cache hits, and all manner of other operations.
So, just write a unit test that excercises the code you want to optimise, set stats on beforehand and dump them out afterwards. Then try a few different strategies and see which one gives you the right combination of numbers. It's not a substitute for a proper performance test harness and a profiler, but it looks like an invaluable tool for diagnosing problems.
Hibernate 3 also ships with a complete statistics and metrics API that allows you to figure out *everything* that is happening under the covers. All you have to do is a.) enable staticstics for the session factory and b.) retrieve the statistics and use them. Getting them an enabling them is easy:
SessionFactory sessionFactory = getSessionFactoryForApplication();
Statistics stats = sessionFactory.getStatistics();
stats.setStatisticsEnabled(true);
The tricky part (or at least the part that requires the most attention) is figuring out what statistics are available, and what they really mean. There are a billion methods available on the top level, but here is a glimpse (note, all of these values are based off of when statistics were enabled):
For more info read post on below link : http://www.javalobby.org/java/forums/t19807.html
Cheers!!!
Ujjwal B Soni
So, just write a unit test that excercises the code you want to optimise, set stats on beforehand and dump them out afterwards. Then try a few different strategies and see which one gives you the right combination of numbers. It's not a substitute for a proper performance test harness and a profiler, but it looks like an invaluable tool for diagnosing problems.
Hibernate 3 also ships with a complete statistics and metrics API that allows you to figure out *everything* that is happening under the covers. All you have to do is a.) enable staticstics for the session factory and b.) retrieve the statistics and use them. Getting them an enabling them is easy:
SessionFactory sessionFactory = getSessionFactoryForApplication();
Statistics stats = sessionFactory.getStatistics();
stats.setStatisticsEnabled(true);
The tricky part (or at least the part that requires the most attention) is figuring out what statistics are available, and what they really mean. There are a billion methods available on the top level, but here is a glimpse (note, all of these values are based off of when statistics were enabled):
For more info read post on below link : http://www.javalobby.org/java/forums/t19807.html
Cheers!!!
Ujjwal B Soni
Subscribe to:
Posts (Atom)