Java Spring and Hibernate development environment - java

Someone told me to learn Web devolpment in Java. So I come across Java Spring. But After exploring I came to know about "Spring and Hibernate development environment" And I am still confuse what is basic diff in it. And are there other frameworks of java etc ? In which wey do Spring MVC ? I am Php and python guy And New in Spring so kindly don't mind if I am wrong in asking question.

Hibernate provides a lot of feasibility while dealing with the database.
It provides with ORM where in you are able to perform database transaction is the form of objects mapped to corresponding table, using configuration xml files.
Spring, on the other hand is a framework that helps you follow the MVC architecture in an effective and efficient way.
It simplifies writing back end code as well as front end stuff providing clear demarcation simultaneously.

Related

JSP, Servlets, Spring, Hibernate

I am new to Java programming. I have completed my training in Core Java.
Planning to learn Spring & Hibernate.
Are JSP & Servlets mandatory to learn Spring & Hibernate?
Kindly guide me on how to proceed..
I am planning to work in Java development. I am not sure how things work in IT company. Do we need to Code everything from scratch or will there be any existing code templates available in the company.
You don't really need to fully learn JSP and Servlets before Spring but you should learn a bit of how it works because you might encounter projects still using Servlets and you even might need to write one for quick tests.
Concerning Hibernate, it's a data access framework which has nothing to do with Servlets or Spring. You can learn it with without both of them.

Is frameworks really necessary for this problem?

I'm creating an online music store application (in Java) for signed and unsigned artist for my client.
I'm currently using Struts 1.3.10 (I was recommended Spring but Spring setup is sort of similar to Struts) for my Web application.
My Database is currently a MySQL 5 (or higher) and I'm using a DAO pattern to talk to it. There are limitations to using Struts and DAO's (e.g. Multiple File upload in Struts is not implemented the same way as multiple String parameters, and for DAO's, there lacks a Publish-Subscribe feature).
Is what I'm doing the best way forward or should I go straight Hibernate (or similar) and move out of Struts? What are the performance implications or technical issues that you've experienced with the same setup I have?
The client doesn't care how I do it as long as it is done.
You could also use both Struts and Hibernate. The key point of Hibernate is that you store whole objects, without having to worry about it. The performance of Hibernate is pretty good. It is easy to use for just storing objects and hard to understand when you want advanced things.
If you've got complete free-rein as to what you an write it in, and assuming that you want to use a Java platform, then do take a look at JBoss Seam and/or Grails too. Both can use Hibernate as the persistence engine and have RAD tools to allow quick construction of skeleton CRUD webapps. Seam is an especially rich framework offering all sorts of built-in features like arbitrary event-listeners, Ajax updates, file-uploads, etc. but takes a bit of getting your head around whereas Grails is easier to get started with.
Struts 1.3 is kind of old now (though still a good MVC framework) and the newer frameworks have better support for handling conversations (i.e. workflow across multiple requests) which Struts 1.x & Hibernate can make a little awkward at times, as well as AJAX features that you might want to implement at some point. Spring MVC which you mention is good too, but is a lighter-weight framework that the ones I mentioned before. Grails is now supported out of SpringSource too, so it should "have legs" so to speak.

How to boost productivity in my Flex/Java stack?

I am embarking on a new RIA project with Java on the backend. I'm the only developer, and the app is a line-of-business application. My current stack looks like this:
MySQL || Spring(JdbcTemplate for data access) || BlazeDS (remoting) || Flex(Cairngorm)
My question is: what changes can I make to improve productivity? Manually coding SQL, server-side entity objects, client-side value objects and all the Cairngorm stuff is obviously a drag, but I'm not sure what higher-level frameworks to introduce.
What Flex/Java stack has served you well?
Manually coding SQL
Hibernate is an option to cut this out.
One thing that may be of interest is Grails with the available Flex Plugin. It's built on Spring, Hibernate and BlazeDS, so it's all there for you. It was unbelieveably easy to get it remoting stored objects and responding to AMF calls. I was using this and then moved over to a RESTful E4X implementation as I found it a lot easier to debug and tweak as I could inspect the server output in a browser and have tighter control over exactly what I returned to my Flex app (lazy loading problems in collections using BlazeDS were a headache at times).
Here is a quick tutorial showing how easy the whole Grails + Flex Plugin stack is: BlazeDS in Grails
I would seriously reconsider using Cairngorm. In my opinion it's a pretty bloated framework that introduces a lot of abstraction you'll never use. Check out:
http://code.google.com/p/swizframework
http://www.spicefactory.org
Both introduce the concept of dependency-injection into your Flex app.
Also +1 for Hibernate. I would use the standard JPA annotations on a Java class and extend that with Hibernate Annotations as you find you need additional functionality.
Check out springsource.org's new Spring BlazeDS Integration Project
Spring BlazeDS Integration is a new
addition to the Spring portfolio, and
a component of the complete Spring Web
stack. This project's purpose is to
make it easier to build Spring-powered
Rich Internet Applications using Adobe
Flex as the front-end client. It aims
to achieve this purpose by providing
first-class support for using the open
source Adobe BlazeDS project and its
powerful remoting and messaging
facilities in combination with the
familiar Spring programming model.
As alternative to hand-coding sql, aside from hibernate, you might wanna consider JPA/Toplink. And since you are already from a Spring camp, check out Spring ActionScript (formerly known as Prana), it's an IOC framework for Flex. It solves many inherent problems in Cairngorm. Also a good IDE that supports Flex/Actionscript like IntelliJ IDEA 8.
Whats missing between Flex and BlazeDS is, it doesnt have any sort of landing page where you have a listing of all the available services by just typing a url on the browser (similar to webservice endpoint).
You can try GraniteDS. It's an alternative to BlazeDS, with an actionScript generator, Spring integration (an Spring security), and if you use an JPA implementation, help you with the Lazy Initialization (in a transparent way).

Helping a beginner for java web application

I have pretty big background of .net, and I've decided that i want to port one of my websites to Java. (now with the asp.net MVC craze, I've figured I'd better learn a more mature approach to MVC).
i've downloaded eclipse (easyeclipse distro to be exact, and am ready and willing to develop my first website in java).
i've programmed j2me application before, so i know the language and some of the framework.
can someone guide me? any advice?
Although I'm not very aware of "asp.net mvc" is all about, I would suggest you to take a look at Spring it may be interesting.
Probably is too complicated at the beginning but when you get the concept it turns out very easy to follow.
Spring has 5 core modules ( which I don't remember exactly ) but they were like:
AOP
ORM
MVC
Core
( some other I'm missing here )
The MVC part uses a lot of annotations to make life easier. There's a very big community around Spring.
Here's an introductory article about spring.
Java has a ton of frameworks you can choose from. The technology stack that I use for my Java development is either:
Spring for IoC.
Hibernate for the data layer.
Struts2 for the MVC framework.
I have also swapped out spring and used Guice for the IoC.
Spring also has MVC, but I tend to like Struts2 better.
I'd recommend looking at Grails, it lets you become comfortable with all the java libraries and frameworks like Spring, SpringMVC, Hibernate, SiteMesh, and so on but gives you a much better DSL for web applications and much more concise code with the Groovy language (think of it as Java with dynamic typing, blocks, closures, and so on).
If you'd rather stick to pure Java I'd recommend looking at the Stripes framework and the following book:
http://pragprog.com/titles/fdstr/stripes
If you interested in web applications specifically, I would recommend using MyEclipse http://www.myeclipseide.com. Basically, this is a version of eclipse with all the web server integration and functionality built in. I've been using it for a few years and it's much easier to develop with than with plain vanilla eclipse. Depending on how much your going to use it, you have to decide whether the $55 annual subscription is worth it for you.
I'm a little confused. does spring framework actually a full blown framework? doesn't Java already have a framework? (by framework i mean all those misc libraries).

Hibernate CRUD à la Ruby on Rails' Scaffolding

Do you know of any tool that would do like Ruby on Rails' Scaffolding (create simple CRUD pages for any particular class to allow quickly populating a database with dummy data), only which used Java classes with Hibernate for database access, and JSP/JSF for the pages?
It is a drag when you are programming one part of an application, but need data that can only be added with another part that is not ready yet, or very cumbersomely by directly inserting it into the DB.
Grails is a very nice Rails-like framework built on top of Spring MVC. For persistence, they use GORM, which is basically an ActiveRecord-like framework built on top of Hibernate. Pretty slick.
If you already have Hibernate entities, they can actually be used immediately in Grails with no additional work.
You can try Telosys Tools, an Eclipse plugin for
code generation (scaffolding) working from an existing database
with customizable Velocity templates.
It's very simple and easy to use.
The tutorial for code generation with Spring MVC and Spring Data is here : https://sites.google.com/site/telosystutorial/
See also : http://tools.telosys.org/
Eclipse Marketplace : http://marketplace.eclipse.org/content/telosys-tools
I'm a little late on this one but it popped up in the "Related" links →
JBoss Seam and it's Seam Gen tasks are exactly what you are looking for (Hibernate + JSF). You can generate an entire web app from a Hibernate fronted database in seconds.
you can use grails. Grails tries to be Groovy on Rails -- uses Rails behind the scene for scaffolding, etc. Since you can pretty much write full scale java code in a groovy class, you can have the CAKE and EAT IT too.
Grails is somewhat different from Rails, even though it was based on Rails and has a similar feel. Grails uses spring to help wire your services together. The environment is not only dynamic (with Groovy) but also allows you to use Java (static environment) as well. It is really cool, especially if you're coming from a java environment. The Grails folks took the Rails idea and expanded it using the Domain Driven Model. Rails is still data model centric where you have to deal a lot with the database to create your objects (which is called a model), where as Grails allows you to design applications using the true domain object model where you deal with objects from the domain class' perspective instead of the database.
There is a good tutorial here on how to do this in Netbeans. I've used this wizard before with good results. Out of the box you can select which persistance framework to use and the JSF pages it produces are quite nice and clean.
Spring + AspectJ + Hibernate + CLI = Spring Roo RAD framework.
Give it a try.

Categories

Resources