casinthecloud / cas-pac4j-oauth-demo

CAS server demo to test the authentication delegation
https://www.casinthecloud.com
76 stars 62 forks source link

How to add Custom JPA configuration to this project #27

Closed vysak closed 8 years ago

vysak commented 8 years ago

I am using cas-pac4j-oauth-client-demo as a base for my demo, I am trying to add Custom Dao and Service for user registration to my system. For that I have extended the ClientAuthenticationHandler.. But I couldnt add Spring @Transactional annotation to my Service which internally calls the service,

Even i am not getting @PersistantContext working,

Here is what I have added the JPA config

<bean id="bouncerDataSource"
            class="com.mchange.v2.c3p0.ComboPooledDataSource"
            p:driverClass="com.mysql.jdbc.Driver"
            p:jdbcUrl="jdbc:mysql://localhost:3306/bouncer"
            p:user="user"
            p:password="password"
            p:initialPoolSize="${database.pool.minSize:6}"
            p:minPoolSize="${database.pool.minSize:6}"
            p:maxPoolSize="${database.pool.maxSize:18}"
            p:maxIdleTimeExcessConnections="${database.pool.maxIdleTime:1000}"
            p:checkoutTimeout="${database.pool.maxWait:2000}"
            p:acquireIncrement="${database.pool.acquireIncrement:16}"
            p:acquireRetryAttempts="${database.pool.acquireRetryAttempts:5}"
            p:acquireRetryDelay="${database.pool.acquireRetryDelay:2000}"
            p:idleConnectionTestPeriod="${database.pool.idleConnectionTestPeriod:30}"
            p:preferredTestQuery="${database.pool.connectionHealthQuery:select 1}"
            />

    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>

    <util:list id="packagesToScan">
        <value>org.leleuj</value>
    </util:list>

    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
          id="jpaVendorAdapter"
          p:generateDdl="true"
          p:showSql="true" />

    <bean id="bouncerEntityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
          p:dataSource-ref="bouncerDataSource"
          p:jpaVendorAdapter-ref="jpaVendorAdapter"
          p:packagesToScan-ref="packagesToScan">
        <property name="jpaProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
                <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
                <prop key="hibernate.jdbc.batch_size">1</prop>
            </props>
        </property>
    </bean>

    <bean id="bouncerTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
          p:entityManagerFactory-ref="bouncerEntityManagerFactory" />

How to get the PersistantContext and @Transactional to make working in this project.

leleuj commented 8 years ago

Please use the CAS mailing list: http://jasig.github.io/cas/Mailing-Lists.html