Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8223815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:50:45+00:00 2026-06-07T14:50:45+00:00

Trying to create a bean in resources.groovy equivalent to this in XML: <bean id=txProxyTemplate

  • 0

Trying to create a bean in resources.groovy equivalent to this in XML:

<bean id="txProxyTemplate" abstract="true"
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager" ref="transactionManager" />
    <property name="target" ref="genericHibernateDAO" />
    <property name="transactionAttributes">
        <props>
            <prop key="save*">PROPAGATION_REQUIRED</prop>
            <!--prop key="analyze">PROPAGATION_REQUIRED</prop -->
            <prop key="validate">PROPAGATION_REQUIRED</prop>
            <prop key="remove*">PROPAGATION_REQUIRED</prop>
            <prop key="create*">PROPAGATION_REQUIRED</prop>
            <prop key="delete*">PROPAGATION_REQUIRED</prop>
            <prop key="add*">PROPAGATION_REQUIRED</prop>
            <prop key="clear*">PROPAGATION_REQUIRED</prop>
            <prop key="set*">PROPAGATION_REQUIRED</prop>
            <prop key="reinitialize">PROPAGATION_REQUIRED</prop>
            <prop key="zap*">PROPAGATION_REQUIRED</prop>
            <prop key="turn*">PROPAGATION_REQUIRED</prop>
            <prop key="*">PROPAGATION_REQUIRED</prop>
        </props>
    </property>
</bean>

Then a second bean which uses this abstract bean as it’s parent:

<bean id="myCoolService" parent="txProxyTemplate">
    <property name="target">
        <bean
            class="com.fourgablesguy.myapp.MyCoolService">
        </bean>
    </property>
</bean>

So far this is what I have in resources.groovy:

import org.springframework.transaction.interceptor.TransactionProxyFactoryBean
import com.fourgablesguy.myapp.MyCoolService

beans = {
    txProxyTemplate(TransactionProxyFactoryBean) {
        transactionManager = ref('transactionManager')
        target = ref ('genericHibernateDAO')
        transactionAttributes = [
            "save*":"PROPAGATION_REQUIRED",
            "validate":"PROPAGATION_REQUIRED",
            "remove*":"PROPAGATION_REQUIRED",
            "create*":"PROPAGATION_REQUIRED",
            "delete*":"PROPAGATION_REQUIRED",
            "add*":"PROPAGATION_REQUIRED",
            "clear*":"PROPAGATION_REQUIRED",
            "set*":"PROPAGATION_REQUIRED",
            "reinitialize":"PROPAGATION_REQUIRED",
            "zap*":"PROPAGATION_REQUIRED",
            "turn*":"PROPAGATION_REQUIRED",
            "*":"PROPAGATION_REQUIRED"
        ]
    }

    myCoolService(MyCoolService) {

    }
}

Just not sure how to setup the txProxyTemplate bean to be abstract and the myCoolService bean to have the txProxyTemplate bean as the parent and the myCoolService bean as the target.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:50:49+00:00Added an answer on June 7, 2026 at 2:50 pm

    This is partially described in the docs, see http://grails.org/doc/latest/guide/spring.html

    In general you make a bean abstract by omitting its class, but in this case since you want to specify the class but only use it as a parent bean you need to set the abstract property explicitly. To make the other bean use it as its parent, set the parent property:

    import org.springframework.transaction.interceptor.TransactionProxyFactoryBean
    import com.fourgablesguy.myapp.MyCoolService
    
    beans = {
    
       txProxyTemplate(TransactionProxyFactoryBean) { bean ->
          bean.abstract = true
    
          transactionManager = ref('transactionManager')
          target = ref('genericHibernateDAO')
          transactionAttributes = [
             "save*":"PROPAGATION_REQUIRED",
             "validate":"PROPAGATION_REQUIRED",
             "remove*":"PROPAGATION_REQUIRED",
             "create*":"PROPAGATION_REQUIRED",
             "delete*":"PROPAGATION_REQUIRED",
             "add*":"PROPAGATION_REQUIRED",
             "clear*":"PROPAGATION_REQUIRED",
             "set*":"PROPAGATION_REQUIRED",
             "reinitialize":"PROPAGATION_REQUIRED",
             "zap*":"PROPAGATION_REQUIRED",
             "turn*":"PROPAGATION_REQUIRED",
             "*":"PROPAGATION_REQUIRED"
          ]
       }
    
       myCoolService(MyCoolService) { bean ->
          bean.parent = ref('txProxyTemplate')
       }
    }
    

    EDIT: After re-reading your bean defs, it looks like this is what you really need:

    myCoolService { bean ->
       bean.parent = ref('txProxyTemplate')
       target = { MyCoolService s ->
          // props for the inner bean
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to create Hibernate Validator bean, and run into this problem creating
I am trying to create a bean and than trying to inject the same
I'm trying to create a service bean that when referenced will be initialized with
I'm trying to create an Hello World JSF application. I have a bean with
I'm trying to create a multiaction web controller using Spring annotations. This controller will
I'm trying to test a stateless session bean with an EntityManager dependency. This is
I'm trying create an immutable object and initialise it from xml config file in
I am trying to create a datasource bean for MySQL from within my Spring
I'm trying to load bean runtime configuration. @Stateless public class MyBean implements MyLocal{ @Resource
I'm trying to create a cache in a webservice. For this I've created a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.