How to execute delete and update operations in RavenDB - ravendb

Just a simple, question reading through the official RavenDB documentation , I understand you are able to execute these operations with the client API functions but you can't with RQL , or is anyway to do it with RQL.

What you are looking for is 'Patching'
Use RQL with the update command
Inside the update you can delete (use del) or modify
See these examples.

Related

How to use ON DUPLICATE KEY on hsqldb 2.3.4

According to the update on hsqldb.org listed here: http://hsqldb.org/web/features200.html
It now supports the mysql syntax ON DUPLICATE KEY in hsqldb 2.3.4, yet Im still getting sql errors when trying to run it. If im reading correctly I may need to set certain flags. But I cant find what to set to be able to use this synatx.
MySQL compatibility is documented in the Guide http://hsqldb.org/doc/2.0/guide/compatibility-chapt.html#coc_compatibility_mysql
You need to execute SET DATABASE SQL SYNTAX MYS TRUE or the equivalent URL property sql.syntax_mys=true to enable it.

For update simulation in oracle using NHiberante

Can any one tell me how to implement for update in oracle using NHibernate? Are there any pre defined clauses for this? If not please tell me how can I implement it.
Read this chapter.
Basically, you need to get your poco using ISession.Get(Of Poco)(id, LockMode.Upgrade).
As a result, that should issue a SELECT ... FROM Poco Where Id = ? FOR UPDATE.
You can also invoke using LockMode.UpgradeNoWait to get a equivalent FOR UPDATE NOWAIT SQL Statement

How can I programmatically run arbitrary SQL statements against my Hibernate/HSQL database?

I'm looking for a way to programmatically execute arbitrary SQL commands against my DB.
(Hibernate, JPA, HSQL)
Query.createNativeQuery() doesn't work for things like CREATE TABLE.
Doing LOTS of searching, I thought I could use the Hibernate Session.doWork().
By using the deprecated Configuration.buildSesionFactory() seems to show that doWork won't work.
I get "use lacks privilege or object not found" for all the CREATE TABLE statements.
So, what other technique is there for executing arbitratry SQL statements?
There were some notes on using the underlying JDBC Statement, but I haven't figure out how to get a JDBC Connection object from Hibernate to try that.
Note that the hibernate.hbm2ddl.auto=create setting will NOT work for me, as I have ARRAY[] columns which it chokes on.
I don't think there is any problem executing a create table statement with a Hibernate native query. Just make sure to use Query.executeUpdate(), and not Query.list() or Query.uniqueResult().
If it doesn't work, please tell us what happens when you execute it, and join the full stack trace of the exception and the SQL query you're executing.
"use lacks privilege or object not found" in HSQL may mean anything, for example existence of a table with the same name. Error messages in HSQL are completely misleading. Try listing your tables using DatabaseMetadata - you have probably already created the table.

How can I change column length using HQL query?

I tried session.createSQLQuery("ALTER TABLE People MODIFY address VARCHAR(1000);").executeUpdate();
but this throws org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
After a lot of googling, the recommendation is to use HQL instead of SQL query to do bulk updates. Not sure how to use HQL to accomplish this. There seems to be no decent HQL documentation for updating column length in a table.
Thanks so much for the help.
I suggest you to run this native SQL query via session.connection().
See section 16.2.2.1. Rules/limitations for using stored procedures of Chapter 16. Native SQL, it's near your ALTER query.
All the rest depends on your database vendor. Good Luck!
I could not find a way. Looks like a limitation. I added a new field and copied over data from old field at start-up!

Getting the SQL from a Doctrine Migration

I have been researching a way to get the SQL statements that are built by a generated Migration file. These extend Doctrine_Migration_Base. Essentially I would like to save the SQL as change scripts.
The execution path leads me to Doctrine_Export which has methods that build the SQL statement and executes them. I have found no way of asking for just them. The export methods found in Doctrine_Export only operate on Doctrine_Record models and not Migration scripts.
From the command line './doctrine migrate version#' the path goes:
Doctrine_Cli::run(cmd)
Doctrine_Task_Migrate::setArguments(args)
Doctrine_Task_Migrate::execute()
Doctrine_Migration::migrate(to)
Doctrine_Migration_Process::Doctrine_Export::various
create, drop, alter methods with sql
equivalents.
Has anyone tackled this before? I really would not like to change Doctrine base files. Any help is greatly appreciated.
Could you make a dev server, and do the migration on that, storing a SQL Trace as you go?you don't have to keep the results, but you would get a list of every command.
Taking into account Rob Farley's suggestion, I modified:
Doctrine_Core::migrate
Doctrine_Task_Migrate::execute
When the execute method is called the optional argument 'dryRun' is checked. If true
then a 'Doctrine_Connection_Profiler' instance is created. The 'dryRun' value is then passed onto
the 'Doctrine_Core::migrate' method. The 'dryRun' value of true allows the changes to rollback when done executing the SQL statements. When the method returns, the profiler is parsed and non-empty SQL statements
not containing 'migration_version' are saved and displayed to the terminal.