How does TransactionScope work?

Hope this helps: http://msdn.microsoft.com/en-us/magazine/cc300805.aspx For those unfamiliar with TransactionScope, it is part of the System.Transactions namespace new to the Microsoft® .NET Framework 2.0. System.Transactions provides a transactions framework fully integrated into the .NET Framework, including but not limited to ADO.NET. The Transaction and TransactionScope classes are two of the most important classes in this namespace. … Read more

Choice of Database schema for storing folder system

Your first schema will work just fine. When you put an index on the FullPath column, use either the case-sensitive BETWEEN operator for queries, or use LIKE with either COLLATE NOCASE on the index or with PRAGMA case_sensitive_like. Please note that this schema also stores all parents, but the IDs (the names) are all concatenated … Read more

How to limit returned results of a JOIN query in MySQL [duplicate]

So assuming we can exclude the user table, it could be rewritten as: select * from expense, transaction where expense_id = transaction_expense_id Now if you want to apply a limit, you could do it like this: select * from expense, transaction where expense_id = transaction_expense_id and expense_id in (select expense_id from expense limit 1) Would … Read more

JPA – create-if-not-exists entity?

I’d like to write a method like <T> T getOrCreate(Class<T> klass, Object primaryKey) This won’t be easy. A naive approach would be to do something like this (assuming the method is running inside a transaction): public <T> T findOrCreate(Class<T> entityClass, Object primaryKey) { T entity = em.find(entityClass, primaryKey); if ( entity != null ) { … Read more

Best way to add a new column with an initial (but not default) value?

To add the column with a default and then delete the default, you can name the default: ALTER TABLE tbl ADD col INTEGER NOT NULL CONSTRAINT tbl_temp_default DEFAULT 1 ALTER TABLE tbl drop constraint tbl_temp_default This filled in the value 1, but leaves the table without a default. Using SQL Server 2008, I ran this … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)