I think that we're sneaking up on it.  Here's an updated pull request that includes the dataSource defined as a spring bean: https://github.com/Jasig/SimpleContentPortlet/pull/9/files

As I understand it, hibernate-attachment.cfg.xml would be where the session factory and data source are defined.  This is also where the configuration for the connection pool lives.  You can see that the properties needed by a datasource, such as connection driver class, uid, pwd, etc. are not here.  Not sure where they were before.  Persistence.xml defines the persistenceUnitName.  ApplicationContext.xml defines the datasource, which overrides anything that would be in persistence.xml or the hibernate.cfg.xml.  The entityManagerFactory wraps the session factory (as I understand it) and explicitly uses the dataSource bean defined above.   Transactions are handled as a bean which injects the entityManagerFactory.

So, I think I've addressed the letter of the request, but not sure I've yet addressed the spirit of the request.  You can see that the dataSource is a generic one (uPortal uses a more custom datasource definition).  There are lots of settings that I didn't do anything with in the entityManagerFactory, and I haven't done anything for sessionFactory (other than explicitly tell it to use C3P0 for connection pooling in hibernate-attachment.cfg.xml).

How's this one?

Thanks,
Michael

----- Original Message -----
From: "Drew Wills" <notifications@github.com>
To: "Jasig/SimpleContentPortlet" <SimpleContentPortlet@noreply.github.com>
Cc: "Michael Gillian" <mgillian@unicon.net>
Sent: Monday, June 2, 2014 4:37:22 PM
Subject: Re: [SimpleContentPortlet] Ip 74 (#8)



In src/main/webapp/WEB-INF/context/applicationContext.xml: > @@ -67,17 +67,26 @@
>          p:order="10" p:cache="true" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/>
>  
>      <!-- Attachments related configuration -->
> -    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean" >
> -        <property name="persistenceUnitName" value="AttachmentsDb"/>
> +    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
> +        <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
> +        <property name="persistenceUnitName" value="AttachmentsDb" /> 

I've only scratched the surface of the docs, but is there a chance to use the dataSource property -- http://docs.spring.io/spring/docs/3.1.1.RELEASE/javadoc-api/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.html#setDataSource(javax.sql.DataSource) -- instead of persistenceUnitName, so we can define the connection pool as a spring bean? 

— 
Reply to this email directly or view it on GitHub .