0

Can we use Spring as Controller and Hibernate as ORM tool for an application with User Interface SWING??

If yes how??

How will be its directory would appear. How all injections will takes place. For simplicity maintaining a environment for saving Text fields input into DATABASE using Hibernate.

Sukupa91
  • 133
  • 3
  • 9
  • Possible duplicate for [Can Spring MVC be used to implement MVC pattern in Swing applications?](http://stackoverflow.com/questions/16386168/can-spring-mvc-be-used-to-implement-mvc-pattern-in-swing-applications) – Gladhus Mar 31 '14 at 18:57

2 Answers2

1

Spring could not be used as Controller in desktop application (Spring MVC is a web framework), but it can be used for features such as autowiring.

However Spring and Swing does not play well together, my last attempt failed due to really inconvinient configuration and lots of overhead code.

Some time ago there was a project called Spring Rich Client, but seems to be abandoned.

Anyway - internet is full of examples of using Swing with Spring, but you have to know that this pair is "not that popular".

Using pair of Hibernate and Spring is not different than in web-application case.

Maciej Dobrowolski
  • 11,561
  • 5
  • 45
  • 67
  • +1 for making it clear , Swing+ Spring makes complication for large bunch of Codes. Anyways the issue is I am not getting how jtextfeild text can be saved into database. Have been googling for last two days, could not find anything relevant. If possible do mention any link for demonstration SWING+SPRING+HIBERNATE. – Sukupa91 Mar 31 '14 at 19:32
  • 1
    It's probably not about how to work with `Swing+Spring+Hibernate`, but how to work with `Hibernate` itself. `JTextField` class has method `getText()` which returns text from the component. Then programmer should use `Hibernate` to persist text. Look at any tutorial about Hibernate, it will become clear how to work with it in non-web environment. – Maciej Dobrowolski Mar 31 '14 at 20:45
0

No. You cannot use Spring as a controller. But you can use core Spring container for using in Dao and Service layer. Hibernate for using Object mapping with Database Table.

Myo
  • 72
  • 3