jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Mod4j: Modeling for Java using Domain Specific Languages
  • MODFORJ-138

The transaction advice is done on the LOCAL service instead of the DOMAIN service

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Not A Bug
  • Affects Version/s: 1.1.0
  • Fix Version/s: None
  • Component/s: DSL for Services
  • Labels:
    None

Description

Currently:

<aop:pointcut expression="execution(* org.company.recordshop.service.OrderServiceModelLocalService.*(..))" id="OrderServiceModelServiceMethods"/>
<aop:advisor advice-ref="txAdviceorderServiceModelService" order="30" pointcut-ref="OrderServiceModelServiceMethods"/>

Ie, the transaction is started when the LOCAL service is entered. This should be the DOMAIN service. In the current situation, a Transaction is still held open when the local service is busy adapting DTOs to domain object and vice versa. Since no business logic is done there, what's the point?

Solution:
Moved to AOP configuration to the applicationContext.xml in the business layer.

I can do this, if all agree it should indeed be in the business layer.

Issue Links

relates to

Bug - A problem which impairs or prevents the functions of the product. MODFORJ-144 No id set for newly added dto's (update-service method)

  • Critical - Crashes, loss of data, severe memory leak.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Jos Warmer added a comment - 01/Oct/09 1:52 AM

Transaction boundaries should be in the business layer, not in the service layer. It seems to me that you are right.

Show
Jos Warmer added a comment - 01/Oct/09 1:52 AM Transaction boundaries should be in the business layer, not in the service layer. It seems to me that you are right.
Hide
Permalink
Vincent Lussenburg added a comment - 01/Oct/09 2:03 AM - edited

However.. if the transaction is closed, the Hibernate session is also closed: this will possibly be an issue for LazyInitialization. I suspect that fixing this issue will not be a walk in the park.

Show
Vincent Lussenburg added a comment - 01/Oct/09 2:03 AM - edited However.. if the transaction is closed, the Hibernate session is also closed: this will possibly be an issue for LazyInitialization. I suspect that fixing this issue will not be a walk in the park.
Hide
Permalink
Johan Vogelzang added a comment - 01/Oct/09 2:25 AM

When the transaction (and Hibernate flush time) bounderies are moved to the domain services, I think also issue MODFORJ-144 will be solved.

Example: class CustomerServiceModelLocalServiceImplBase ...

public CustomerWithOrdersAndOrderLines updateCustomer(
			CustomerWithOrdersAndOrderLines object) {
		//...

		result = customerWithOrdersAndOrderLinesTranslator.fromDto(object,
				result);
		result = customerServiceModelDomainService.updateCustomer(result);
                
                // Transaction and flushing ended. Now all updated Customers and associatied objects have an Id.
		
               return customerWithOrdersAndOrderLinesTranslator.toDto(result);
	}
Show
Johan Vogelzang added a comment - 01/Oct/09 2:25 AM When the transaction (and Hibernate flush time) bounderies are moved to the domain services, I think also issue MODFORJ-144 will be solved. Example: class CustomerServiceModelLocalServiceImplBase ...
public CustomerWithOrdersAndOrderLines updateCustomer(
			CustomerWithOrdersAndOrderLines object) {
		//...

		result = customerWithOrdersAndOrderLinesTranslator.fromDto(object,
				result);
		result = customerServiceModelDomainService.updateCustomer(result);
                
                // Transaction and flushing ended. Now all updated Customers and associatied objects have an Id.
		
               return customerWithOrdersAndOrderLinesTranslator.toDto(result);
	}
Hide
Permalink
Eric Jan Malotaux added a comment - 02/Oct/09 2:43 PM

No, according to the Application Architecture (http://www.mod4j.org/documentation/1.0.1/application-architecture/mod4j-application-architecture.pdf) the transaction boundaries are in the service layer. You should be able to freely let business services call each other without bothering about transactions. Transactions are as much as possible a clients concern and so should be as close as practically possible to the client.

Besides on a more practical point, as Vincent already pointed out, you would lose the benefit of Hibernate lazy initialization that with the use of dto's and translaters (that should really be renamed mappers) has become really useful for the first time!

Show
Eric Jan Malotaux added a comment - 02/Oct/09 2:43 PM No, according to the Application Architecture (http://www.mod4j.org/documentation/1.0.1/application-architecture/mod4j-application-architecture.pdf) the transaction boundaries are in the service layer. You should be able to freely let business services call each other without bothering about transactions. Transactions are as much as possible a clients concern and so should be as close as practically possible to the client. Besides on a more practical point, as Vincent already pointed out, you would lose the benefit of Hibernate lazy initialization that with the use of dto's and translaters (that should really be renamed mappers) has become really useful for the first time!
Hide
Permalink
Vincent Lussenburg added a comment - 03/Oct/09 12:28 AM

Ok, that's a good point..

Show
Vincent Lussenburg added a comment - 03/Oct/09 12:28 AM Ok, that's a good point..
Hide
Permalink
Vincent Lussenburg added a comment - 05/Nov/09 11:41 AM

Transaction boundary is at the correct location.

Show
Vincent Lussenburg added a comment - 05/Nov/09 11:41 AM Transaction boundary is at the correct location.

People

  • Assignee:
    Unassigned
    Reporter:
    Vincent Lussenburg
Vote (0)
Watch (0)

Dates

  • Created:
    25/Sep/09 9:32 AM
    Updated:
    05/Nov/09 11:41 AM
    Resolved:
    05/Nov/09 11:41 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.