• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference

 
Kalpesh K Rawal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any give me the difference between HIbernate and EJB?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB is a specification for distributed enterprise java objects. You have Stateless and Stateful Session Beans and Entity Beans. Hibernate is on Object Relational Mapping tool to map relational database tables to your object model.

Hibernate is a solution to the problems of using Entity Beans. So it is like a replacement for the Entity Bean part of EJBs. However, JBoss's 4.x implementation of EJB 3.0 Entity Beans is in fact Hibernate 3.x

Mark
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

I have seen one application where stateless sessionbeans are used with hibernate ,but data is not persisted i.e setCacheable is called on query object with false value.

do you think use of hibernate serves any advantage in this case ?

Cheers
-P
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have seen one application where stateless sessionbeans are used with hibernate ,but data is not persisted i.e setCacheable is called on query object with false value.

setCacheable() flags a whether a Query can be cached in the second-level cache. Its got nothing to do with persistence.
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setCacheable() flags a whether a Query can be cached in the second-level cache. Its got nothing to do with persistence


gosh...was under very wrong impression,then how to tell hibernate not to persist data.

also my orignal question,is it good to have hibernate in this framework ?

Thanks a lot Paul

Cheers
-P
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To tell Hibernate not to persist, you just don't flush the Session or commit.

But why would you use Hibernate if you didn't want to store and update data in a database?

Mark
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

sorry for the confusion with statemen below.
I have seen one application where stateless sessionbeans are used with hibernate ,but data is not persisted i.e setCacheable is called on query object with false value.


I meant there is no caching of data at hibernate layer.


-Praful
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is always caching of data in the Hibernate Session (which is why it is also known as the first level cache). That is implicit and unavoidable, unless you constantly flush the Session (which would be a pointless thing to do).
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
intresting...Thanks a bunch Paul

Cheers
-Praful
 
uma prasath
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi paul,
"There is always caching of data in the Hibernate Session (which is why it is also known as the first level cache). That is implicit and unavoidable, unless you constantly flush the Session (which would be a pointless thing to do). "


As per my understanding, how i can visualize caching is hibernate will fetch data from the table and populate it in a database object and store it in memory. Is it right ??

Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly right.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic