I have a simples question. I have been trying to learn Grails by my own, and i managed to do a simple application using Grails/Gorm.
1 ) Later, i decided to use Mysql instead of Gorm - i just needed to configure the 'DataSource' and download the driver.
2 )So if i want to use hibernate between both (Grails and MYSQL) like this:
http://www.grails.org/doc/latest/guide/15.%20Grails%20and%20Hibernate.html, i need to make an 'hibernate.cfg.xml' file, and specify my mysql database url, user, pw etc .. and i have to map each Class in Grails for MySql columns.
So what is the diference between 1) and 2) ? and what exactly hibernate does. Give examples if possible
PS. Please correct me if i said something wrong, im kinda new to this
I think you are a bit confused here.
GORM is not a database, it is a ORM that maps you Groovy classes to database tables. It uses Hibernate under the covers to achieve this (Hibernate is also an ORM).
The default database Grails uses is an in-memory HSQL DB. If you want to use MySQL instead of that, all you need to do is change the settings in conf/DataSource.groovy.
You don't need to create any Hibernate xml files. That part of the documentation you've linked to is to allow people with existing Hibernate domain models to easily re-use them.
Hope this helps clear things up.
cheers
Lee
Related
My question is related to use Hibernate into JHipster.
I'd like to know if there exists a way to work with Hibernate by using an already existing database without generating manually all the entities.
I'd like to know if there exists this sort of reverse engineering way to proceed.
If not, I would like to know what is the best strategy to follow in order to work with an existing database (I'm working with MySQL).
This is more of a Q/A kind of question, i am looking for an example to replicate and learn.
Is there a way to use two different database at different servers from my spring application.
Currently my project uses MySql internally, so i have no issues to bind my JPA repositories or Entities file. It uses the database without any problem.
The problem is that i want to use one entity class that is a table in Sql server (entirely different from the mysql database that i am using currently for all entitiy class).
Please can you provide me example or the steps to be taken towards accomplishing this. I just want to point my Entity class to different database.
There is a whole example there.
You basically create 2 spring configurations, each defining its own DataSource bean.
I am new learner to NHibernate. I am trying out samples with MSSQL database. We all know query using MSSQL is different from MYSQL database. If i need to use this sample for MYSQL, do i need to change anything other than configuration settings? Also i need to know is there anything that is not possible because of NHibernate?
There are multiple ways of configuring NHibernate.
What you need to set is called:
The dialect is responsible for converting IQueryable, ICriteria or so called HQL (hibernate query language) to the SQL of the corresponding database.
But if you want to have this general, you must pay attention to the ID (in some cases even use locking). SQL has so called auto-identity, while Oracle works with sequencers. But NHibernate has it's own ways of generating identity.
I would advise you to:
use latest NHibernate (not older than 3.3.x.x)
try out fluent nhibernate mapping
eventually find some example on nhibernate + fluent + unity/structure map (DI framework) - mostly you find something related to DDD projects
I tried using sequelize and node-orm as well - but is there a way to reuse existing mysql schema? I Have a db schema defined with tables in mysql and wanted to use this with my node.js app (using express). So, I don't have to write all the define methods of defining tables again.
Any help appreciated...
I went through bunch of stackoverflow questions already such as: Which ORM should I use for Node.js and MySQL?
Thanks,
JP
Checkout bookshelf.js, it doesn't require that you define the schema in the model layer.
i was asked to do a book manager at university with hibernate and mysql. I have a simple question. If i choose to do a web application, grails already uses hibernate. GORM runns over hibernate. so to use mysql i only need to configure jdbc grails drivers and that's it?
i mean, "for the project you must use hibernate and mysql" - this are the requirements. So can i do that way?
thanks in advance,
JM
Yes, of course you can.
You'll need to get the MySQL JDBC driver from this location.
Grails? When you're new to programming? Whose idea was this?
Personally, I think that taking on all these unknowns is risky for someone who's "new to programming." Do you know anything about SQL or JDBC? Have you ever written a web project before? This could be difficult.
I don't know how to be more specific. Download the JDBC JAR from the link I gave you.
I'd recommend that you start with a JDBC tutorial first. Hibernate is not for you - yet.
Hibernate is an object-relational mapping tool (ORM). It's a technology that lets you associate information in relational database tables to objects in your middle tier. So if you have a PERSON table with columns id, first, and last Hibernate will let you associate those data with the private data members in your Person Java class.
That sounds easy, but it gets complicated quickly. Your relational and object models might have one-to-many and many-to-many relationships; Hibernate can help with those. Lazy loading, caching, etc. can be managed by Hibernate.
But it comes at a cost. And it can be difficult if you aren't familiar with it.
If you have a deadline, I'd recommend creating a Java POJO interface for your persistence classes and doing the first implementation using JDBC. If you want to swap it out for Hibernate later on you can do it without affecting clients, but you'll have a chance of making progress without Hibernate that way.