I'm running OrientDb 2.2.6 using a plocal connection. I'm translating from one domain specific query language to OrientDb SQL. Since I need to translate a like command that allows regular expressions, I'd like to pass a regular expression similar to
[Ss]ay.*
but it looks like OrientDb 2.2 only supports the wild card '%'. Can Orient handle a regular expression like the one above? If not, do I need to create a custom function? Maybe there's an object in Orient's API that I can use instead?
you can use something like
Select from v where name MATCHES "<regex>"
link1
link2
Related
I want to customise the SQL that Slick generates for a standard insert before it is sent to the DBMS, so that I can add extra DBMS-specific debugging options that Slick doesn't natively support. How can I do that?
At the action level (i.e., with a DBIO), you can replace the SQL Slick will use via overrideStatements. Combined with statements to access the SQL Slick generates, that would give you a place to jump in and customize the SQL.
Bare in mind, you'll be working with Strings with these two API calls.
A simple example would be:
val regularInsert = table += row
// Switching the generated SQL to all-caps is a terrible idea,
// and may not run in your database, but it will do as an example:
val modifiedSQL = regularInsert.statements.map(_.toUpperCase())
val modifiedInsert = regularInsert.overrideStatements(modifiedSQL)
// run modifiedInsert action as normal
The next step up from this would be to implement a custom database profile to override the way inserts are created to include debugging.
This is more involved: you'd want to extend the profile you're currently using, and dive into the Slick APIs to override various methods to change the insert behaviour. For example, you might start by exploring the existing Postgres profile if that's the database you're using.
However, the above example can be applied per-insert as needed which may be enough for what you need.
If you are using a connection pool such as HikariCP, you can put a Java breakpoint on the ProxyConnection.prepareStatement(String sql) method, or the equivalent method in whatever connection pool library you are using. Then when the SQL of interest is about to be prepared by that method, use your debugger's "evaluate expression" functionality to modify/replace the value of sql.
This won't work if the library you are setting the breakpoint on is not open source, or for some other reason is compiled without debugging information.
I'm trying use Cypher query with Spark. I'm following this guide: https://github.com/opencypher/morpheus
but I'm not able to use path patterns p=()-[]->().
My main problem is that I want to calculate the level of relationship.
For example:
p=(u)-[:rel]-(f) return length(p)
Thank's for answer.
Is there any way to use Regular expressions in Query builder.
Is JCR supports this?
Any pointers on this would be helpful for us.
Thanks in advance.
San
If this QueryBuilder API documentation where to believed as being definitive, then no I would not say there is regex support. However there does seem to be some wildcard support that may be useful. What I would do in this case is try to craft a query around all the properties that you know of about your nodes that can identify them. For example using the debug tool at http://x.x.x.x:4502/libs/cq/search/content/querydebug.html a query like may give you some ideas
type=cq:Page
path=/content/myapp
nodename=*s
1_relativedaterange.property=jcr:content/cq:lastModified
1_relativedaterange.lowerBound=-48h
Where I'm looking for pages in my app content, that end is 's', that have been modified in the last 48 hours. You can even filter by resourceType, template, and any other property that can help you find those nodes. You may even consider adding your own just for this query.
Maybe you can have a sling job, where in Java you could iterate the node names (or whatever) and you do have regex, and tag nodes with a meaningful property that you can then use to query using the query builder.
I have ormlite integrated into an application I'm working on. Right now I'm trying to build in functionality to easily switch from automatically inserting data to the database to outputting the equivalent collection of insert statements to a file for later use. The data isn't user input but still requires proper escaping to handle basic gotchas like apostrophes.
Ideas I've burned through:
Dao.create() writes to the database directly, so that's a no-go.
QueryBuilder can't handle inserts.
JdbcDatabaseConnection.compileStatement() might work but the amount of setup required is inappropriate.
Using a java.sql.PreparedStatement has a reasonable enough interface (if toString() returns the SQL like I would hope) but it's not compatible with ormlite's connection types.
This should be very easy and if it is, I can't find the right combination of method calls to make it happen.
Right now I'm trying to build in functionality to easily switch from automatically inserting data to the database to outputting the equivalent collection of insert statements to a file for later use.
Interesting. So one hack would be to use the MappedCreate class. The MappedCreate.build(...) method takes a DatabaseType and a TableInfo which is available from the dao.getTableInfo().
The mappedCreate.toString() exposed the generated INSERT statement (with a prefix) which might help but you would still need to convert the ? arguments to be the actual values with escaped quotes. That you would have to do in your own code.
Hope this helps somewhat.
I'm wondering if there's any possible way how to use or implement SELECT query into JavaM API for GT.M database system. I'm using version 0.1, since I haven't found any other version ( https://github.com/Gadreel/javam/blob/master/README.md ).
If there's no option yet, could you recommend me any other API for this DBMS, using Java? I know there's some gtm4j ( http://code.vistaehr.com/gtm4j ), but it takes advantage of springframework, which is not convenient for me.
I'm new with GT.M and I just want to test, how to connect to it using Java and use some basic queries. Thanks a lot for your advices.
The database side of GT.M is a hierarchical key-value store, so features like SELECT (I'm guessing you want a full SQL SELECT) needs to be implemented by some framework (either an existing framework or one created by you).
From a quick look at the JavaM API, it seems it only offers/showcase a Java interface to the features offered by GT.M. So I think you would have to implement the SQL SELECT feature yourself, in Java.
That said, it is possible that what you wanted to use a SQL SELECT for can be done easilly using the standard GT.M / JavaM API, so there would be no need to implement a full SQL SELECT.
Actually, you could use M to write a parser for your SELECT command syntax. And would certainly be easier to do with the GTMJI plug-in for full-duplex GT.M/Java communication that FIS have just released.