Search Results

Search found 1380 results on 56 pages for 'transactions'.

Page 13/56 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Forcing a method to be non-transactional in JPA (Eclipselink)

    - by rhinds
    Hi, I am developing an application using Eclipselink and as part of the app I need to be able to manipulate some of the objects which involves changing data without it being persisted to the database (i merging/changing objects for some batch generation processes). I am reluctant to change the data in the Entity objects, as there is a risk that even though i have not marked the methods as @Transactional, this method could in the future be inadvertantly called from within a transactional method and these changes could be persisted. So my question is, is there anyway to get around this? Such as force a method to always be non-transactional regardless; terminate any transactionality as soon as the method is started; etc. I know there is a .detach() method that can detach the objects from the Entity Manager, however, there are many objects and this seems like a potentially error prone fail-safe on my code.

    Read the article

  • Does rails do a rollback if I use begin...rescue?

    - by codeman73
    I'd like to add a begin...rescue block to one of my controllers create method, in order to log better info and construct the correct error message to return to the client. Does the rescue in any way 'interrupt' the rollback process? I'm assuming rails automatically does a rollback. When does it happen? Has it already happened by the time I get in the rescue clause? I'm using mySQL on Dreamhost and I think they use innoDB.

    Read the article

  • NHibernateUnitOfWork + ASP.Net MVC

    - by Felipe
    Hi Guys, hows it going? I'm in my first time with DDD, so I'm begginer! So, let's take it's very simple :D I developed an application using asp.net mvc 2 , ddd and nhibernate. I have a domain model in a class library, my repositories in another class library, and an asp.net mvc 2 application. My Repository base class, I have a construct that I inject and dependency (my unique ISessionFactory object started in global.asax), the code is: public class Repository<T> : IRepository<T> where T : Entidade { protected ISessionFactory SessionFactory { get; private set; } protected ISession Session { get { return SessionFactory.GetCurrentSession(); } } protected Repository(ISessionFactory sessionFactory) { SessionFactory = sessionFactory; } public void Save(T entity) { Session.SaveOrUpdate(entity); } public void Delete(T entity) { Session.Delete(entity); } public T Get(long key) { return Session.Get<T>(key); } public IList<T> FindAll() { return Session.CreateCriteria(typeof(T)).SetCacheable(true).List<T>(); } } And After I have the spefic repositories, like this: public class DocumentRepository : Repository<Domain.Document>, IDocumentRepository { // constructor public DocumentRepository (ISessionFactory sessionFactory) : base(sessionFactory) { } public IList<Domain.Document> GetByType(int idType) { var result = Session.CreateQuery("from Document d where d.Type.Id = :IdType") .SetParameter("IdType", idType) .List<Domain.Document>(); return result; } } there is not control of transaction in this code, and it's working fine, but, I would like to make something to control this repositories in my controller of asp.net mvc, something simple, like this: using (var tx = /* what can I put here ? */) { try { _repositoryA.Save(objA); _repositoryB.Save(objB); _repositotyC.Delete(objC); /* ... others tasks ... */ tx.Commit(); } catch { tx.RollBack(); } } I've heared about NHibernateUnitOfWork, but i don't know :(, How Can I configure NHibernateUnitOfWork to work with my repositories ? Should I change the my simple repository ? Sugestions are welcome! So, thanks if somebody read to here! If can help me, I appretiate! PS: Sorry for my english! bye =D

    Read the article

  • Transaction within a Transaction in C#

    - by Rosco
    I'm importing a flat file of invoices into a database using C#. I'm using the TransactionScope to roll back the entire operation if a problem is encountered. It is a tricky input file, in that one row does not necessary equal one record. It also includes linked records. An invoice would have a header line, line items, and then a total line. Some of the invoices will need to be skipped, but I may not know it needs to be skipped until I reach the total line. One strategy is to store the header, line items, and total line in memory, and save everything once the total line is reached. I'm pursuing that now. However, I was wondering if it could be done a different way. Creating a "nested" transaction around the invoice, inserting the header row, and line items, then updating the invoice when the total line is reached. This "nested" transaction would roll back if it is determined the invoice needs to be skipped, but the overall transaction would continue. Is this possible, practical, and how would you set this up?

    Read the article

  • How can i attach data to a JTA transaction? (or uniquely identify it)

    - by kwyjibo
    I have a getStockQuote() function that will get a current stock quote for a symbol from the stock market. My goal is that within a JTA transaction, the first call to getStockQuote() will fetch a stock quote, but all subsequent calls within the same transaction will reuse the same stock quote (e.g.: it will not try to fetch a new quote). If a different transaction starts, or another transaction runs concurrently, i would expect the other transaction to fetch its own stock quote on its first call. This would be similar to how you can configure JPA providers to only fetch a database row from the database once, and use the cached value for subsequent access to the same database row within the transaction. Does anyone have tips on how this can be achieved?

    Read the article

  • Transaction within IF THEN ELSE doesn't commit

    - by boris callens
    In my TSQL script I have an IF THEN ELSE structure that checks if a column already exists. If not it creates the column and updates it. IF NOT EXISTS( SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'tableName' AND COLUMN_NAME = 'columnName')) BEGIN BEGIN TRANSACTION ALTER TABLE tableName ADD columnName int NULL COMMIT BEGIN TRANSACTION update tableName set columnName = [something] from [subquery] COMMIT END This doesn't work because the column doesn't exist after the commit. Why doesn't the COMMIT commit?

    Read the article

  • Can you modify SQL DB schema in a transaction to know if all changes were applied?

    - by Chris F
    As part of my (new) database version control methodology, I'm writing a "change script" and want the change script to insert a new row into the SchemaChangeLog table if the script is executed successfully, or to reverse changes if any single change in the script fails. Is it possible to do schema changes in a transaction and only if it gets committed to then do the INSERT? For example (psuedo-code, I'm not too good with SQL): SET XACT_ABORT ON BEGIN TRANSACTION PRINT 'Add Col2 to Table1' IF NOT EXIST (SELECT * FROM sys.columns WHERE NAME='Col2' AND object_id=OBJECT_ID('Table1')) BEGIN ALTER TABLE [dbo].[Table1] ADD Col2 int NULL END -- maybe COMMIT here? INSERT INTO SchemaChangeLog VALUES(...) COMMIT TRANSACTION

    Read the article

  • What is the benefit to wrapping every sql/stored proc invocation in a transaction?

    - by MatthewMartin
    The following code executes one stored procedure. The stored procedure has only one command in it. Is there any benefit to wrapping everything in a transaction, even it only has one SQL statement in it (or one stored proc that has only one sql statement)? In the sample code below, if the delete fails, it fails. There is nothing else to be rolled back (it seems). So why is everything wrapped in a transaction anyhow? using (ITransactionManager transMan = repository.TransactionManager()) using (IController controller = repository.Controller()) { transMan.BeginTransaction(); try { //DELETE FROM myTable where Id=@id controller.Delete(id); transMan.CommitTransaction(); } catch { transMan.RollbackTransaction(); throw; } }

    Read the article

  • How to bring coordination between file system and database?

    - by Lock up
    I am working on a online file management project. We are storing references on the database (sql server) and files data on the on file system. We are facing a problem of coordination between file system and database while we are uploading a file and also in case of deleting a file. First we create a reference in the database or store files on file system. The problem is that if I create a reference in the database first and then store a file on file system, but while storing files on the file system any type of error occur, then the reference for that file is created in the database but no file data exist on the file system. Please give me some solution how to deal with such situation. I am badly in need of it. This case happens also while we deleting a file?

    Read the article

  • Force Hibernate To Save A Specific POJO

    - by user1695626
    I have some code calling a webservice and it returns an id. I am saving this id in the database using hibernate. I have a filter that opens the session and commits it, rolling back when any exception occurs within the contained code. Since there is no way to get back the id returned by the webservice I would like to save this in the database EVEN if there is an exception that occurred later on in the code. Is there anyway to do this using the same session?

    Read the article

  • How do detect that transaction has already been started?

    - by xelurg
    I am using Zend_Db to insert some data inside a transaction. My function starts a transaction and then calls another method that also attempts to start a transaction and of course fails(I am using MySQL5). So, the question is - how do I detect that transaction has already been started? Here is a sample bit of code: try { Zend_Registry::get('database')->beginTransaction(); $totals = self::calculateTotals($Cart); $PaymentInstrument = new PaymentInstrument; $PaymentInstrument->create(); $PaymentInstrument->validate(); $PaymentInstrument->save(); Zend_Registry::get('database')->commit(); return true; } catch(Zend_Exception $e) { Bootstrap::$Log->err($e->getMessage()); Zend_Registry::get('database')->rollBack(); return false; } Inside PaymentInstrument::create there is another beginTransaction statement that produces the exception that says that transaction has already been started.

    Read the article

  • Storing task state between multiple django processes

    - by user366148
    I am building a logging-bridge between rabbitmq messages and Django application to store background task state in the database for further investigation/review, also to make it possible to re-publish tasks via the Django admin interface. I guess it's nothing fancy, just a standard Producer-Consumer pattern. Web application publishes to message queue and inserts initial task state into the database Consumer, which is a separate python process, handles the message and updates the task state depending on task output The problem is, some tasks are missing in the db and therefore never executed. I suspect it's because Consumer receives the message earlier than db commit is performed. So basically, returning from Model.save() doesn't mean the transaction has ended and the whole communication breaks. Is there any way I could fix this? Maybe some kind of post_transaction signal I could use? Thank you in advance.

    Read the article

  • Spring OpenSessionInViewFilter with @Transactional annotation

    - by Gautam
    This is regarding Spring OpenSessionInViewFilter using with @Transactional annotation at service layer. i went through so many stack overflow post on this but still confused about whether i should use OpenSessionInViewFilter or not to avoid LazyInitializationException It would be great help if somebody help me find out answer to below queries. Is it bad practice to use OpenSessionInViewFilter in application having complex schema. using this filter can cause N+1 problem if we are using OpenSessionInViewFilter does it mean @Transactional not required? Below is my Spring config file <context:component-scan base-package="com.test"/> <context:annotation-config/> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basename" value="resources/messages" /> <property name="defaultEncoding" value="UTF-8" /> </bean> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:location="/WEB-INF/jdbc.properties" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.databaseurl}" p:username="${jdbc.username}" p:password="${jdbc.password}" /> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> <property name="configurationClass"> <value>org.hibernate.cfg.AnnotationConfiguration</value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${jdbc.dialect}</prop> <prop key="hibernate.show_sql">true</prop> <!-- <prop key="hibernate.hbm2ddl.auto">create</prop> --> </props> </property> </bean> <tx:annotation-driven /> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean>

    Read the article

  • Saving an ActiveRecord non-transactionally.

    - by theFunkyEngineer
    My application accepts file uploads, with some metadata being stored in the DB, and the file itself on the file system. I am trying to make the metadata visible in the application before the file upload and post-processing are finished, but because saves are transactional, I have had no success. I have tried the callbacks and calling create_or_update() instead of save(), all to no avail. Is there a way to do this without re-writing the guts of ActiveRecord::Base? I've even attempted naming the method make() instead of save(), but perplexingly that had no effect. The code below "works" fine, but the database is not modified until everything else is finished. def save(upload) uploadFile = upload['datafile'] originalName = uploadFile.original_filename self.fileType = File.extname(originalName) create_or_update() # write the file File.open(self.filePath, "wb") { |f| f.write(uploadFile.read) } begin musicFile = TagLib::File.new(self.filePath()) self.id3Title = musicFile.title self.id3Artist = musicFile.artist self.id3Length = musicFile.length rescue TagLib::BadFile => exc logger.error("Failed to id track: \n #{exc}") end if(self.fileType == '.mp3') convertToOGG(); end create_or_update() end Any ideas would be quite welcome, thanks.

    Read the article

  • Hibernate/Spring: getHibernateTemplate().save(...) Freezes/Hangs

    - by ashes999
    I'm using Hibernate and Spring with the DAO pattern (all Hibernate dependencies in a *DAO.java class). I have nine unit tests (JUnit) which create some business objects, save them, and perform operations on them; the objects are in a hash (so I'm reusing the same objects all the time). My JUnit setup method calls my DAO.deleteAllObjects() method which calls getSession().createSQLQuery("DELETE FROM <tablename>").executeUpdate() for my business object table (just one). One of my unit tests (#8/9) freezes. I presumed it was a database deadlock, because the Hibernate log file shows my delete statement last. However, debugging showed that it's simply HibernateTemplate.save(someObject) that's freezing. (Eclipse shows that it's freezing on HibernateTemplate.save(Object), line 694.) Also interesting to note is that running this test by itself (not in the suite of 9 tests) doesn't cause any problems. How on earth do I troubleshoot and fix this? Also, I'm using @Entity annotations, if that matters. Edit: I removed reuse of my business objects (use unique objects in every method) -- didn't make a difference (still freezes). Edit: This started trickling into other tests, too (can't run more than one test class without getting something freezing) Transaction configuration: <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <!-- the transactional semantics... --> <tx:attributes> <!-- all methods starting with 'get' are read-only --> <tx:method name="get*" read-only="true" /> <tx:method name="find*" read-only="true" /> <!-- other methods use the default transaction settings (see below) --> <tx:method name="*" /> </tx:attributes> </tx:advice> <!-- my bean which is exhibiting the hanging behavior --> <aop:config> <aop:pointcut id="beanNameHere" expression="execution(* com.blah.blah.IMyDAO.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="beanNameHere" /> </aop:config>

    Read the article

  • Oracle global_names DELETE problem

    - by jyzuz
    I'm using a database link to execute a DELETE statement on another DB, but the DB link name doesn't conform to global naming, and this requirement cannot change. Also I have global_names set to false, and cannot be changed either. When I try to use these links however, I receive: ORA-02069: - global_names parameter must be set to TRUE for this operation Cause: A remote mapping of the statement is required but cannot be achieved because GLOBAL_NAMES should be set to TRUE for it to be achieved. - Action: Issue `ALTER SESSION SET GLOBAL_NAMES = TRUE` (if possible) What is the alternative action when setting global_names=true is not possible? Cheers, Jean

    Read the article

  • DBA's say no to SQL Server DTC?

    - by NabilS
    I am trying to get our DBA's to enable DTC on a cluster of SQL Server 2005. Unfortunately they keep refusing. Their argument that they would need to set up a dedicated host for DTC (Could take months!!) as it is not a matter of ticking a few boxes. Is this true? How intrusive is DTC on a shared environment such as a SQL farm. Do I have an argument against this? Thanks

    Read the article

  • The time-to-reach-queue has elapsed

    - by nieve
    I'm attempting to send a message to a remote private queue from an error queue with powershell. The code I use looks like this: $msg = $src_q.Peek() $msg.Label = GetLabelWithoutFailedQueue($msg) $msg.UseDeadLetterQueue = $true $msg.UseTracing = $true $msg.AcknowledgeType = [System.Messaging.AcknowledgeTypes]::NegativeReceive $msg.TimeToBeReceived = [System.TimeSpan]::FromSeconds(10) $msg.TimeToReachQueue = [System.TimeSpan]::FromSeconds(10) $tx = new-object System.Messaging.MessageQueueTransaction $tx.Begin() $dest_q.Send($msg, $tx) $tx.Commit() The message keeps on appearing on the transactional dead letter queue with the class: "The time-to-reach-queue has elapsed." Anyone's got any idea what could trigger such an error? The queue definitely exists- I do manage to peek it. Also, the reason I get the message from the error queue by peeking is just for testing purposes; I have tried doing the same thing with Receive and the result is the same.

    Read the article

  • MySQL transaction conundrum

    - by David Faitelson
    I need to perform several inserts in a single atomic transaction. For example: start transaction; insert ... insert ... commit; However when MySQL encounters an error it aborts only the particular statement that caused the error. For example, if there is an error in the second insert statement the commit will still take place and the first insert statement will be recorded. Thus, when errors occur a MySQL transaction is not really a transaction. To overcome this problem I have used an error exit handler where I rollback the transaction. Now the transaction is silently aborted but I don't know what was the problem. So here is the conundrum for you: How can I both make MySQL abort a transaction when it encounters an error, and pass the error code on to the caller?

    Read the article

  • What benefit would I get when using MessageQueueTransaction with ReceiveCompleted event in MessageQu

    - by Jeffrey
    I understand the benefit when using MessageQueueTransaction in the below scenario where 5 messages will be wrapped in a single transaction and until the transaction has been committed 5 individual ReceiveCompleted events will then be raised. using(var t = new MessageQueueTransaction()) using(var q = new MessageQueue("queue path here")) { t.Begin(); q.Send(new Message); q.Send(new Message); q.Send(new Message); q.Send(new Message); t.Commit(); } I understand the usefulness when using Peek() and Receive() which has been mentioned in this question. However I am wondering would I get any benefit when combining MessageQueueTransaction with ReceiveCompleted event.

    Read the article

  • Can JPA do batch update | put | write | insert as pm.makePersistentAll() does in GAE/J

    - by Kenyth
    I searched through multiple discussions here. Can someone just give me a quick and direct answer? And if with JPA you can't do a batch update, what if I don't use transaction, and just use the following flow: em = emf.getEntityManager // do some query // make some data modification em.persist(..) // do some query // make some data modification em.persist(..) // do some query // make some data modification em.persist(..) ... em.close() How does this compare to batch update with regard to performance, and compare to a single transaction commit, measured by RPC calls to datastore server, CPU cycles per request, or so. Does every call to em.persist(..) before em.close() trigger a RPC call to the datastore server? Thanks very much for any response!

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >