-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Configuring Hibernate for multiple webapps
PostPosted: Wed Sep 11, 2013 8:43 am 
Newbie

Joined: Wed Sep 11, 2013 8:27 am
Posts: 2
Hi,

I'm looking for some basic advice on using the same hibernate entities across multiple webapps. I've taken a "shoot-first-ask-questions-later" attitude towards Hibernate, but I'm running into a problem with lazy fetching. I'm stumped.

Here's my situation. I have a project with multiple webapps and maven projects. One of them is a "company-entities" project that has the configuration for Hibernate (hibernate.cfg.xml) and all the annotated classes. I then have a "company-client" project, intended to manage the logic of composing and building entities across webapps. I have a "company-admin" interface that runs on Spring MVC ( 3.2.4.RELEASE ), where editors can manage their content, and a "company-server" project that uses JAX-RS to achieve more or less the same thing. The difference is that the JAX-RS API imposes strict RESTful interface to be used by external apps. There will be later additions for client facing webapps and mobile apps.

Try as I might, I can't render entities with a ( OneToMany/ManyToMany etc ) in Spring MVC or JAX-RS. ( short of using FetchType.EAGER which creates it's own set of problems ).

I can find some information on how to set up a SessionOpenInViewFilter and SessionOpenInViewInterceptor for Spring MVC, but I don't really understand how that applies to my situation.

I guess my question is, should I use "hibernate.cfg.xml" to configure how Hibernate manages the entities in an underlying project, potentially overwriting it in specific webapps? Or should I only configure Hibernate in the respective webapps that depend on the "company-entities" project?

Hope someone can find the time to help me along with a few suggestions...


Top
 Profile  
 
 Post subject: Re: Configuring Hibernate for multiple webapps
PostPosted: Wed Sep 11, 2013 9:07 am 
Newbie

Joined: Wed Sep 11, 2013 8:27 am
Posts: 2
Hm, perhaps a bit more concrete question. Do I need to configure multiple session factories, or can I stick to a single configuration? If so, how do I set up an "Open Session In View Pattern" in Spring and Jersey?

PS. here's the config in my hibernate entitites project.

Code:
<hibernate-configuration>

   <session-factory>

      <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

      <property name="connection.driver_class">org.postgresql.Driver</property>
      <property name="connection.url">jdbc:postgresql://localhost:5432/company</property>
      <property name="connection.username">***</property>
      <property name="connection.password">***</property>

      <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>

      <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
      <property name="current_session_context_class">thread</property>

      <property name="show_sql">true</property>
      <property name="hbm2ddl.auto">update</property>

      <mapping class="com.company.entities.Entity1" />
      <mapping class="com.company.entities.Entity2" />
      <mapping class="com.company.entities.EntityN" />

   </session-factory>

</hibernate-configuration>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.