Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Gigaspaces and hibernate

Why (per current gigaspaces and hibernate integration WIKI) is suggests to use gigaspaces on top of hibernate? I think best combo would be opposite use hibernate as layer between application and gigaspaces.

Current design looses all benefits of using ORM for application layer. Can you , please, clarify on this design decision?

Thanks

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2047]{quote}

asked 2007-11-21 21:30:01 -0500

mgrouch gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

Hi,

the integration between GigaSpaces and Hibernate can be done both ways. You can replace the default Hibernate's second level cache with GigaSpaces (which was the question you raised) or you can you hibernate between GigaSpaces and a database for persistency reasons.

Replacing the second level cache with GigaSpaces is documented forHibernateORMUsers">http://www.gigaspaces.com/wiki/display/GS6/GigaSpacesforHibernateORMUsers">url=http://www.gigaspaces.com/wiki/display/GS6/GigaSpacesforHibernateORMUsershere/url and http://www.hibernate.org/201.html">url=http://www.hibernate.org/201.htmlhere/url

Michael

answered 2007-11-22 04:48:03 -0500

michaelm gravatar image
edit flag offensive delete link more
0

Let me clarify the question

Let's say I have an application layered like this

Web DAO Hibernate Query Cache Second Level Cache DB

and now we want to gridify it and take advantage of gigaspaces partitioned cache and grid for higher throughput

would it be possible to replace

Query Cache Second Level Cache

with Gigaspaces.

We still want to use hibernate HQL for queries and ORM with objects which have relationships on application layer.

Is this possible? Thanks

answered 2007-11-21 21:47:03 -0500

mgrouch gravatar image
edit flag offensive delete link more

Comments

To really get scaling you need to stop thinking about databases and ORM, but think instead about getting objects moved around your system.

With GigaSpaces you can have the reliability of a database, but have a much faster system. GigaSpaces keeps all the objects in RAM, at least 2 copies on separate machines if you choose it that way.

Whenever you put a DB into the picture you will, ultimately, be limited by its throughput and latency, so the trick to getting the system to scale and go fast is to design as much as possible without a DB, and only go to/from a DB when you absolutely must (which is much less frequently than most people think!)

So this becomes an architectural thing - GigaSpaces can be used in the way you describe but, if you're serious about performance, scaling, latency and reliability (not to mention grid computing and "free" messaging) then it makes much more sense to make GigaSpaces your middleware and let the DB fade into the background. You can still have a DB, but its playing a background role.

HTH

Toby (A GigaSpaces employee)

toby gravatar imagetoby ( 2007-11-21 21:56:04 -0500 )edit

What about all relations between objects which ORM provides? Will I still have it when gigaspaces is directly linked to the app and ORM is between DB and gigaspaces? Let's say I have User and Account relationship mapped so that User has getAccounts() method. When user is loaded from space can I just call getAccounts() to load them into space?

I'm a noob with gigaspaces so this might be a dumb question...

Thanks

mgrouch gravatar imagemgrouch ( 2007-11-21 22:49:05 -0500 )edit

{quote}What about all relations between objects which ORM provides? Will I still have it when gigaspaces is directly linked to the app and ORM is between DB and gigaspaces? Let's say I have User and Account relationship mapped so that User has getAccounts() method. When user is loaded from space can I just call getAccounts() to load them into space?{quote}

GigaSpaces allows you to share full objects, with state and behavior, in the clustered space. It thereby provides more powerful abstractions than an O-R mapping can. It is straightforward to implement a getAccounts() method on a User object to retrieve all associated Accounts from the space.

{quote}I'm a noob with gigaspaces so this might be a dumb question...{quote}

Not at all. Space Based Architecture (SBA) is a somewhat different way of approaching problems than is the traditional n-tier approach you described in your original post. It takes some effort to learn, but the reward is that you're able to build far more scalable, resilient, peformant systems far more simply than you possibly could with more traditional technologies.

patrickm gravatar imagepatrickm ( 2007-11-22 07:23:05 -0500 )edit

I understand scalability and increased throughput provided by this architecture (cache, grid, delayed commits, partitioning). What keeps bothering me is increased amount of coding required to implement it. ORM (hibernate) is used in very limited way laying underneath gigaspaces. In classical ORM setup I would not need to implement getAccounts() method at all.

And now we seems to be heading the way to implement some kind of DAO for application to access spaces and that layer largerly mimics functionality of ORM which hidden by spaces and not available anymore. Its like we reimplementing ORM again for application layer while we have another one it used in limited way just for persistence pass-through by spaces.

Application layer also loses ability to query using HQL (correct me if I'm wrong). I just do not understand how HQL could fit there.

Are there any best practices on implementing layer tying application with spaces? Some nice common code examples?

If hibernate had only ability to fetch objects by ids and no HQL or Criteria query capabilities it would be much less useful. How can I use these features with gigaspaces architecture?

I've used hibernate ORM heavily in past projects and I might need to break that mentality I guess.

Thanks, You input is much appreciated

mgrouch gravatar imagemgrouch ( 2007-11-22 12:14:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2007-11-21 21:30:01 -0500

Seen: 130 times

Last updated: Nov 21 '07