in Education by
Regarding the Castle Automatic Transaction Management Facility; I'm having some difficulties getting operations to actually save to the database without flushing the session. I'm using the following components * NHibernate.dll v3.1.0.4000 * Castle.Core.dll v2.5.2.0 * Castle.Windsor.dll v2.5.3.0 * Castle.Facilities.NHibernateIntegration.dll v1.1.0.0 * Castle.Services.Transaction.dll v2.5.0.0 * Castle.Facilities.AutoTx.dll v2.5.1.0 I have followed the Castle documentation very closely and have not been able to resolve my issue. My (web-)application follows the MVP pattern. The key parts of the (transactional) presenter-service are shown below: _ Public Class CampusEditPresenter Inherits BasePresenter(Of ICampusEditView) Public Sub New(ByVal view As ICampusEditView) MyBase.New(view) End Sub ... _ Public Overridable Sub Save() Implements ICampusEditPresenter.Save ' Simplified Using session As ISession = _sessionManager.OpenSession() Dim campus As New Campus() campus.Code = _view.Code campus.ShortDescription = _view.ShortDescription campus.LongDescription = _view.LongDescription campus.StartDate = _view.StartDate campus.EndDate = _view.EndDate session.Save(campus) End Using End Sub End Class This presenter-service is registered in an installer: container.Register( _ Component.For(Of CampusEditPresenter) _ .Interceptors(Of DebugLoggingInterceptor) _ .LifeStyle.Transient) and resolved by the view (in the base): Public Class BasePage(Of TPresenter) Inherits Page Protected _presenter As TPresenter ... Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init _presenter = _container.Resolve(Of TPresenter)(New With {Key .view = Me}) End Sub ... End Class Public Class CampusEdit Inherits BasePage(Of CampusEditPresenter) Implements ICampusEditView ... Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click _presenter.Save() End Sub ... End Class I have registered the NHibernate and Transaction facilities in an XML configuration file as follows: NHibernate.Driver.OracleClientDriver, NHibernate [removed] false NHibernate.Dialect.Oracle10gDialect, NHibernate true 1, false 0, yes 'Y', no 'N' NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle web auto-quote and I have registered the SessionWebModule Http module in my Web.config: ... Any ideas as to why this may not be working? I can get everything working when I a) instansiate my own transactions from the ISession instance and maually commit these transactions, or if I b) use the Automatic Transaction Management AOP-mechanism AND manuall flush the session instance (though I shouldn't have to manually do this). I would have also thought that SessionWebModule IHttpModule (which follows the open-session-per-request pattern) would cause my entities to be persisted, but this doesnt seem to be happening... JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
So I worked out the TransactionInterceptor was not getting registerd on my components. After downloading the Castle.Facilities.AutomaticTransactionManagement source from github and stepping through, I found my issue and managed to resolve it. Basically the TransactionFacility adds a contributor, TransactionComponentInspector, to the ComponentModelBuilder, which allows for some additional configuration contribution whilst building the component. In the case of the TransactionComponentInspector, it looks for a "Transactional" class attribute on the component and if it exists it will register a TransactionInterceptor on the component. However, my components were never getting contributed to by the TransactionComponentInspector. To configure/register my components on the container, I use Installers. I configure the container itself using XML, which references these installers as well as any facilities (e.g. NHibernate-integration/logging etc.). Anyways, I believe it may have been some kind of ordering issue whereby my components might have been getting registered before the transaction facility. As such components registered before the TransactionFacility were not getting contributed-to by the TransactionComponentInspector and were therefore not getting a TransactionInterceptor registered on the component. Once I realised this I manually configured the container (with the correct order of things) and everything seemed to work!!! Now I've got to try and work out how to do this in my XML configuration. If I can't, I guess I'll dump this and go for fluent configuration of the container (e.g. in the global HttpApplication). [edit] see below: _container = New WindsorContainer() ' TransactionFacility must be registered before components. _container.AddFacility(Of TransactionFacility)() _container.Install(Configuration.FromXmlFile("Configs\services.xml"))

Related questions

0 votes
    What is a transaction code in SAP MM or material management?...
asked Mar 15, 2021 in Technology by JackTerrance
0 votes
    Explain ACID in context of transaction management....
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
    The prince abdicated the crown and returned to his castle. Abdicated means… Gave up. Sold. Reinvested into. Auctioned....
asked Jan 2, 2021 in Education by JackTerrance
0 votes
    The explanation facility of an expert system may be used to ____________ (a) construct a diagnostic model (b) ... & expedite the debugging process Please answer the above question....
asked Sep 21, 2022 in Education by JackTerrance
0 votes
    The _taskbar is more flexible and provides an easy navigation facility Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    If you see jqGrid demo : http://www.trirand.com/blog/jqgrid/jqgrid.html Section : Advanced --> ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    If you see jqGrid demo : http://www.trirand.com/blog/jqgrid/jqgrid.html Section : Advanced --> ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    I am migrating my Java,Tomcat, Mysql server to AWS EC2. I have already attached EBS volume for storing MySql ... you guide. Thanks Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am migrating my Java,Tomcat, Mysql server to AWS EC2. I have already attached EBS volume for storing MySql ... you guide. Thanks Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    How To Persist Root Device Volume In Amazon Ec2 Instance ?...
asked Mar 12, 2021 in Technology by JackTerrance
0 votes
    What is the difference between save() and persist() method in Hibernate?...
asked Feb 4, 2021 in Technology by JackTerrance
0 votes
    What is Difference between save(), saveOrUpdate() and persist() in Hibernate Session?...
asked Feb 4, 2021 in Technology by JackTerrance
0 votes
    Which technique is being investigated as an approach to automatic programming? (a) generative CAI (b) specification by ... ) all of the mentioned Please answer the above question....
asked Sep 21, 2022 in Education by JackTerrance
0 votes
    Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    I'm writing by own blogging engine in PHP with a MYSQL backend database. MY question is: How would ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
...