Reputation: 155
I have a theoretical question about using object-relational database in, for example, Java. I know that there is something like ORM (example: Hibernate) which provide mapping database tables to classes but also I can make operations through JDBC (creating connection and execute sql queries through Java). Is there any way to do the queries in object databases using this second approach (ordinary JDBC mechanism)? Thanks for any help and maybe some samples ;)
Upvotes: 0
Views: 175
Reputation: 818
I found something that might be related to what Caro2 was asking, not regarding object databases unfortunately, but with a graph database called Neo4J.
That particular graph database has a JDBC driver that accepts Cypher queries (one of Neo4J graph query languages) through a JDBC interface. It lets you query the graph database, not with SQL, but with its own query language. It supports the JDBC API, such as executeQuery and executeUpdate methods, and lets you navigate ResultSets etc.
So this means that it is possible for an object oriented database to have a JDBC driver, as long as the developers can match the object oriented query language to the JDBC API. One could then query the OODB directly using JDBC, placing query/update/delete commands in the OO query language syntax, using its JDBC driver.
Upvotes: 0
Reputation: 70909
There are true object-oriented databases, called Object Stores. Think of them as persistent storage of classes that would normally reside in memory. If that is what you meant by " Is there any way to do the queries in object databases using this second approach" then the answer is no.
True Object Stores cannot support SQL queries for a number of reasons.
Data in objects are encapsulated, so selecting off an object's internal data fields becomes cumbersome and subject to the encapsulation rules for exposure (public, private, protected, package-protected).
Data in Object Stores are connected, in the sense that their references are also stored intact. So "selecting" an object gives you the entire web of objects that it directly and indirectly references.
Object relational query languages are more similar to object-like syntax that can be translated to SQL queries. This means that Object relational query languages are not a SQL analog for Object Stores. An Object Stores directly supports a different language for query, and having a Object query language would be of no greater use in pulling out the data than having a SQL query.
Unfortunately, I am unaware of a standard query language for Object Stores. Perhaps there is one, but Object Stores are used infrequently enough that I wouldn't be surprised if it was "a bunch of 'standards' fighting to be the one true standard". Even with SQL, the standard is pretty loosely defined, being more like "a bunch of dialects sharing a basic grammar structure".
Upvotes: 0
Reputation: 818
I don't think you can access a pure Object Oriented database using JDBC. Not without a driver that translates SQL into the object query language (i.e., does the opposite of what a ORM framework does).
Upvotes: 0
Reputation: 66637
ORM are wrapper on top of SQL
. They are not rocket science. If you don't prefer Object Query Languagues (like HQL
), yes you can do plain SQL
queries (for sure in Hibernate
using method createSQLQuery(...))
EDIT:
Based on Ricardo comment, if you are looking for SQL on object database, AFAIK, I don't think there is any support at this moment.
Upvotes: 1