Fórumok

Need sample Hibernate+Spring Portlet with DB interaction

thumbnail
Dhandapani S, módosítva 11 év-val korábban

Need sample Hibernate+Spring Portlet with DB interaction

Regular Member Bejegyzések: 176 Csatlakozás dátuma: 2009.03.24. Legújabb bejegyzések
Hi All,

I need to develop sample portlet with db interaction using hibernate+Spring. If any one have sample war file, please share.

Thanks in advance.

Regards
Dhans006
thumbnail
David H Nebinger, módosítva 11 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
You have a bunch of examples already, all based on ServiceBuilder. Anything service builder based uses hibernate and spring.
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
As David replied, liferay is using Spring + Hibernate under the covers.

You can go through tutorial in Development to create a sample portlet.
http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/service-build-5
thumbnail
Vishal Panchal, módosítva 11 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Expert Bejegyzések: 289 Csatlakozás dátuma: 2012.05.20. Legújabb bejegyzések
Hi Dhandapani S,

As I seen your post I decide to make sample portlet with db interaction using hibernate+Spring.

And I did it..!!

.war file is attached below..

Please let me know if any inputs require.

Thanks & Regards,
Vishal R. Panchal
thumbnail
David H Nebinger, módosítva 11 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
Vishal, it's not that it can't be done (I've done it a number of times myself), it's that it shouldn't be done...

The problem with this approach comes in when other plugins need the same entities.

You have two choices:

1. copy the mapping file(s) and implementation classes to the new plugin.
2. put all of the plugins that need access into the same war file.

The problem with #1 is that you're copying code around. You must manage the synchronization of code changes out and about and hopefully you'd eventually figure out a way to do it. The bigger problem is that you increase your resource consumption without being aware of it... If you add the classes to another plugin, the other plugin will need a database connection for the hibernate stuff, so you have (at least) 2 db connections used for this (probably more because you don't want to choke the code because of no DB connection). As you add more plugins and copy the code around, these same resource requirement increases also get copied.

Now step #2 solves that problem, although it too gets to be ugly. If you have all of your plugins in a single plugin, pretty soon that plugin is going to be difficult to manage. Then there's the whole deployment issue (I only changed one file in this portlet, but since it's in one war we now have to test all of them, etc.).

Then there's the Liferay way. The liferay way has you using Service Builder. You create a plugin, put your service.xml in there and generate all of the code. You add methods to the XxxLocalServiceImpl classes to flush out your API, but in the end you've got a fine layer for local (and possibly remote) data access usage. You can create other completely separate plugins, but rather than getting copies of all of the code, you get a thin service jar which is the shim to the shared service implementation.

In Liferay it's definitely the way to go.
thumbnail
Vishal Panchal, módosítva 11 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Expert Bejegyzések: 289 Csatlakozás dátuma: 2012.05.20. Legújabb bejegyzések
Hi David H Nebinger,

I got the whole issue.
Thank you for the explanation your time and consideration.
I will never use these approach as it has many drawbacks as emoticon resource consumption , number of db connection and finally repeating the code (service method) as number of plugins increase to use the same.

But one question , Is there any way through we can make JAR file of our service classes which can be shared by multiple plugins locally / remotely.?


Thanks & Regards,
Vishal R. Panchal
thumbnail
David H Nebinger, módosítva 11 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
You automatically get that. When you run SB, in the WEB-INF/lib folder you'll find the service jar.

You have two options to share it:

1) the old way, deploy your plugin, shut down the app server, move the service jar from the deployed war's WEB-INF/lib directory to the application server's global lib dir (i.e. lib/ext in tomcat), then start the server. All plugins will have visibility to the service jar and can call the methods directly.

2) the new way, for each plugin that will be using the service, add the plugin providing the service as a required deployment context in liferay-plugin-package.properties. The IDE will copy the service jar in for you, so you don't have to do any of the stuff in #1. It does have it's own quirks, of course (as a compile-time thing of the IDE, it is possible to have different versions of the service jar floating around if you don't deploy all consumers when you deploy the provider).
thumbnail
Vishal Panchal, módosítva 11 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Expert Bejegyzések: 289 Csatlakozás dátuma: 2012.05.20. Legújabb bejegyzések
Sir,

That one I got but what I was thinking that "If we follow my approach than Is there any way through we can make JAR file of our service classes which can be shared by multiple plugins locally / remotely.? "

So I mean in Spring+hibernate portlet can we make a jar file of service classes (as same as service builder) which can be shared across multiple plugins instead of coping the classes to each plugin (or put all plugins in same .war file) ..?



Thanks & Regards,
Vishal R. Panchal
thumbnail
David H Nebinger, módosítva 11 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
The magic of SB is that it creates a shim level to cross the class loader boundary between web applications. When you look inside a SB-based service jar, you see a lot of classes with Clp on the end, these are the class loader proxies.

When you create an instance of a class in one web app there are typically a lot of things that you have to worry about when accessing that class in another web app because of the class loader boundary.

Sure, you could eventually emulate all of the learned knowledge and experience built into SB code. But the question is, why would you want to?
thumbnail
Vishal Panchal, módosítva 11 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Expert Bejegyzések: 289 Csatlakozás dátuma: 2012.05.20. Legújabb bejegyzések
Sir,

Thanks for the deep explanation.

Finally I will use SB which has a great magic and will not try to emulate the same emoticon.

Thank You..!!

Thanks & Regards,
Vishal R. Panchal
sravan kumar, módosítva 9 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Junior Member Bejegyzések: 78 Csatlakozás dátuma: 2013.02.19. Legújabb bejegyzések
Hi,

I created a project a based on war file, it it showing @BeanReference can not found exception,(classNOtFoundException)


let me know if any jar files i need to include.
thumbnail
Meera Prince, módosítva 9 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

Liferay Legend Bejegyzések: 1111 Csatlakozás dátuma: 2011.02.08. Legújabb bejegyzések
Hi

The following is liferay spring hibernate portlet it may help you..

http://www.liferaysavvy.com/2013/12/liferay-spring-portlet.html

Regards,
Meera Prince
Pavan B Modi, módosítva 9 év-val korábban

RE: Need sample Hibernate+Spring Portlet with DB interaction

New Member Bejegyzések: 2 Csatlakozás dátuma: 2014.08.29. Legújabb bejegyzések
Hi Vishal,

I need you assistance for following issue.

https://www.liferay.com/community/forums/-/message_boards/message/42040102

Please take a look in post.