how to switch spring 4 + Hibernate with mongoDB project to MySQL? - java

I searching too much for my question in www.stackoverflow.com, but nothing helps me.so I have to post my question.
I have completed my project in spring 4 + Hibernate with MongoDB. now client requirement is MySQL. so I have to switch that project in Hibernate with MySQL.
I have tried to write code in the project. but it shows to much error in session as NullPointerException and another about my service and repository related.
so can you suggest any demo for a Hibernate with MySQL configuration in spring MVC 4.? and yes which configuration is good? XML based or java class based?

Please follow the link, it would help you to get start with Spring MVC + Hibernate (MySQL).
https://examples.javacodegeeks.com/enterprise-java/spring/mvc/spring-mvc-hibernate-tutorial/
About configuration: I personally prefer Java based configuration (not XML)
For xml configuration please have a look at:
http://www.codejava.net/frameworks/spring/spring-4-and-hibernate-4-integration-tutorial-part-1-xml-configuration

You should use Spring Boot instead of Spring MVC 4. Spring Boot will help you a lot as not too many configuration. You can easily switch to this without too much changes. No persisting of entity need to write as you can use Spring Data JPA for that.
You can following Spring Boot + Hibernate example by StartWithJava.
http://www.startwithjava.com/spring-boot-web-application-using-themeleaf/

Related

Is it possible to use memSQL/SingleStore with Spring Data JPA?

I want to use SingleStore database with my Spring Boot Application which uses Spring Data JPA. How it can be achieved?
To leverage SingleStoreDB with Spring Boot, you would use the JDBC connectors for both technologies - Spring + SingleStore. If you are using some ORM style features, use the mysql dialect. If you run into issues you can raise them here, on the forum or to support if you're an active customer.

Integrating Hibernate to Spring running on embedded jetty

I have just returned to Spring after 5 years of gap and it seems lot is changed. I have a task to create a REST Service using Spring with hibernate as an ORM, So far I am able to run a basic Rest Service using embedded jetty and able to make GET/POST calls, the next is to integrate hibernate into it so that the data fetch/Sent operation actually use MySQL instead of sending hard-coded response(which I have done currently).
The issue is earlier I used to work on Spring MVC using Tomcat where we had web.xml to define the dispatcher servlet and application-context which in turn were used to define hibernate config and other beans declaration, but now having embedded jetty I am not finding a way to integrate hibernate to my REST app, Is the way to add configuration is changed from XML to class based config. I searched over internet but maybe I am out of words or not using correct keywords, in short, Have no luck finding some solution to integrate hibernate to my Spring app which is using embedded jetty.
Could some please breif me about the recent changes or point me to the right tutorial ?
Any help appreciated, thanks in advance !
ps - I have used this example to progress so far https://github.com/pethoalpar/SpringMvcJettyExample
Yes , lot of changes in these 5 years and one of the game-changer is spring-boot
If you want to build a brand new project especially if you want to run the web application on the embedded container such as Jetty , you can check out spring-boot.It already provides integration with Jetty , hibernate and Spring MVC REST service.
The end result is that you just need to change a little bit configuration (most probably the DB connection info) and you can quickly get a production-ready REST service backed by JPA/Hibernate which can just run without any XML configuration anymore.
There are tons of tutorials in Internet talking about how to do it . You should easily find them out such as this using the keywords something likes "springboot webservice hibernate jetty" etc.

Migration from Hibernate to EclipseLink in Spring Boot

I have an application created in Spring Boot https://github.com/JonkiPro/REST-Web-Services. I need to replace Hibernate provider with EclipseLink.The problem is that practically the entire configuration is found only in the application. properties https://github.com/JonkiPro/REST-Web-Services/blob/master/web/src/main/resources/application.yml file and I don't know what to change to EclipseLink.
There is an example project from Spring on how to use Spring Boot with EclipseLink. Please refer:
https://github.com/spring-projects/spring-data-examples/tree/master/jpa/eclipselink

How to use ibatis in spring boot application using annotations?

I am using spring boot in my application, i want to know how to use Spring boot, iBatis and MySQL. While i am trying to find the reference for Spring boot with iBatis projects its automatically redirect to myBatis. I need a example project or site for referring this. I have example for mybatis but i want ibatis with spring boot.
I think, you shouldn't think how you may connect them. Just read docs about iBatis(MyBatis). But the following link special for you http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/

Spring-JPA-MVC-Hibernate Session per Request with Java Config

I have a spring-jpa-mvc-rest-hibernate web application that I use Java Config almost 99% on the whole app.
How can I configure Session per Request on pure Java Config? Preferable not using hibernate specific code, if that is possible.
I'm using Spring 4.2.2.RELEASE, Spring Data 1.11.0.RELEASE, Spring JPA 1.9.0.RELEASE, Spring WebMVC 4.2.2.RELEASE and Hibernate 5.0.2.Final.
Thanks a lot.

Categories

Resources