Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Gemini Web with Hibernate(Configuration issue)
Gemini Web with Hibernate [message #889444] Tue, 19 June 2012 08:36 Go to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 211
Registered: February 2012
Location: Düsseldorf
Senior Member
Hi,
I just want to share my experience with gemini web in conjunction with spring/hibernate. I tried to configure hibernate using spring.orm and I had a lot of problems with it. First of all I start with an existing mapping layer with old style .hbm.xml mapping files (so no annotations).

In detail I tried the following:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource"/>
    <property name="mappingDirectoryLocations">
    	<list>
   	  <value>classpath:/root/domain/pkg</value>
	</list>
    </property>
</bean>


With the following result:
Caused by: java.io.FileNotFoundException: OSGi resource[classpath:/root/domain/pkg/|bnd.id=46|bnd.sym=GeminiServerPlugin] cannot be resolved to absolute file path because it does not reside in the file system: bundleresource://46.fwk24463001/root/domain/pkg/
	at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:242)
	at org.springframework.osgi.io.OsgiBundleResource.getFile(OsgiBundleResource.java:342)



I did some debugging. This fails because ResourceUtils.getFile() expects a file scheme in the provided url. But the way the directory location is resolved, there is no such scheme defined in the url.

Second try. My mapping files reside next to my java domain models. Therefore I tried to just add all *.hbm.xml file which are located in my classpath:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource"/>
    <property name="mappingLocations">
       <value>classpath:**/*.hbm.xml</value> 
    </property>
</bean>


This may work if the bundle is completely build and wrapped in a jar. In my case I am trying to run this from within eclipse. What happens is that each mapping file is found twice. Once in the bin\ and once in the src\ folder which - for some reason - is in the search classpath which is used to add the files.

The only working solution that I found is the following:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource"/>
    <property name="mappingLocations">
       <value>osgibundle:/META-INF/hibernate/**/*.hbm.xml</value>
    </property>
</bean>


In which case I have to copy my mapping files into the respective /META-INF/hibernate folder.

I am just curious to know if somebody experienced similar behaviour? Am I missing something?

Regards,
Thorsten
Re: Gemini Web with Hibernate [message #890625 is a reply to message #889444] Fri, 22 June 2012 17:31 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 216
Registered: July 2009
Senior Member
Quote:
I am just curious to know if somebody experienced similar behaviour? Am I missing something?


Perhaps only the fact that Gemini has a JPA subproject for persistence Smile You might want to give that a go and see if you find it easier.

-Mike
Re: Gemini Web with Hibernate [message #890808 is a reply to message #890625] Sat, 23 June 2012 05:02 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 211
Registered: February 2012
Location: Düsseldorf
Senior Member
Thanks for the hint Mike. If I would go for a new project I would certainly give Gemini JPA a try. But my goal is to port an existing project to OSGI. The domain model consists of a couple of hundret objects which are all mapped with hibernate (not to mention all the Criteria and HQL-queries). To my knowledge Gemini JPA only provides integration with EclipseLink.
Re: Gemini Web with Hibernate [message #892050 is a reply to message #890808] Wed, 27 June 2012 01:04 Go to previous message
Michael Keith is currently offline Michael KeithFriend
Messages: 216
Registered: July 2009
Senior Member
Gemini JPA uses EclipseLink as the JPA provider, but the main point is that the application does not need to assume any provider; it just needs to use standard JPA. Sounds like you are stuck with a legacy app that was written using proprietary API, though, so I guess you just have to make things work as best you can.

-Mike
Previous Topic:Value of Blueprint when using Spring?
Next Topic:Looking for maven repository for Gemini Blueprint
Goto Forum:
  


Current Time: Fri Dec 19 04:11:29 GMT 2014

Powered by FUDForum. Page generated in 0.01622 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software