Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 274 Vote(s) - 3.43 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hibernate with MongoDB

#1
I'm looking for resources showing how to integrate MongoDB with Hibernate (preferably from within spring) so that I can switch between a RDBMS and a NoSql alternative: does anyone have experience doing this?
Reply

#2
You can't easily do this. The point of Hibernate is to map Java Objects to a relational database. Although Hibernate abstracts a lot of details away you still need to understand how relational databases work with things such as foreign and primary keys, and the performance implications of queries you run. MongoDB requires an entire different way of designing your database focusing on objects instead of columns and tables. while you may be able to create a Hibernate dialect for MongoDB creating a design that would work on both a relational database and a NoSql database will give you a design that works poorly on both.
Reply

#3
Well just to give you an example, I am doing somehting simmilar. In ColdFusion, Hibernate is integrated and in order to save your Hibernate Object, you hvae to do EntitySave(Obj). However what we have done is build the Orm object, and then use a mongoDB Coldfusion component and just save the object by going mongo.Save(obj,collectionName).
Reply

#4
May this blog helps:

[To see links please register here]

Here Dror Bereznitsky describes nicely how to integrate a sping/hibernate based solution with mongodb.
Reply

#5
There is also [kundera][1], which uses JPA-annotations to read/write your object from/to a mongodb. If you ara familiar with hibernate, it should be quite straightformard to use.

I recently tried [Morphia][2], which takes the same approach, but with its own annotations.
It works fine


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#6
Migration would be easier if you use Spring MongoTemplate (similar to HibernateTemplate). <br>Among its features is support for JPA annotations (although, I'm not sure to what extent).<br>
See more:

[To see links please register here]


You'll need the following:<br>

1. Add spring-data-mongodb JAR to your project (available in maven
central).
2. Add mongo-java-driver JAR to your project (available in
maven central).
3. Use the provided MongoTemplate class in a similar
manner to HibernateTemplate. E.g.:
`mongoTemplate.findById(id, MyClass.class);`<br>
`mongoTemplate.insert(myObject);`

Here's a concrete example with code: [use-spring-and-hibernate-with-mongodb][1]


[1]:

[To see links please register here]

Reply

#7
What about [Hibernate OGM][1]? It provides JPA for *No-SQL* databases.


[1]:

[To see links please register here]

Reply

#8
There is nice work done earlier as:

-

[To see links please register here]

-

[To see links please register here]


refer to these links. it will be helpful to you.
Reply

#9
For the sake of completeness, [PlayORM][1] also supports MongoDB now. PlayORM is an object NoSQL mapping solution so you can write POJO’s and let it deal with all the details of marshalling/unmarshalling to MongoDB. Visit its [documentation][2] here


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#10
If you are using Java then you can use **Hibernate OGM** it provides Java Persistence support for **NoSQL** databases.

For more details visit

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through