I have been using the Schema.getTables() method in jOOQ to get the list of tables in my schema, but today I found out that method is returning the list of tables that existed when we executed jOOQ's code-generation, not the tables that exist at this point in time.
My specific use case is we create tables over time (automatic partitions) and our Java service does some operation on them.
Is there a way in jOOQ to get the current list of tables from the DB?
I could resort to querying information_schema.tables directly, but I'd prefer to reuse a method from jOOQ if one is available.
You can access your runtime meta information via jOOQ's DSLContext.meta() API, which is a jOOQ wrapper over JDBC's DatabaseMetaData.
Related
We are using Datastore export feature for exporting datastore entities and importing them in Big Query table. It works perfectly fine.
The only problem is that the entities imported in big query tables do not have 'id' column but '__key__.id'.
We are using a hack(which is unnecessary overhead) for now get 'id' column generated by following query written to target table.
select key.id As id ,* from projectId.datasetId.ImportedTable
Actually, this transfer has be automated via cron jobs and there is no scope for such hack there. so wanted to check if there is any way that imported table by itself, expose ID column.
Can the way we generate entities and choose its Primary column strategy play any role here?
As per documentation, when importing data to BigQuery from Datastore, BigQuery creates a RECORD type for each entity unique key. As this is automated it can't be modified the way is it done.
Maybe a good possibility will be updating the entities to add an extra property and copy the ID so this way the column will be named ID instead of key.id once the import is done to BigQuery.
As this feature is not yet included in the export service between Datastore and BigQuery, you can create a Feature Request in Google Cloud Platform's public issue tracker.
I have a sequence created using flyway in postgres which should start from 10000.
I want to get the next value of the sequence using JPA and not a native query , since i have different db platforms being run at different cloud providers.
I'm not able to find a JPA query to get the next value of a sequence, please redirect me to the right page if i am missing something already ..
Thanks for any help in that area though already!
P.S : I found this link which helps me doing the same with native query.
postgresql sequence nextval in schema
I don't think this is possible in a direct way.
JPA doesn't know about sequences.
Only the implementation knows about those and utilizes them to create ids.
I see the following options to get it to work anyway:
create a view in the database with a single row and a single column containing the next value. You can query that with native SQL which should be the same for all databases since it is a trivial select.
Create a dummy entity using the sequence for id generation, save a new instance and let JPA populate the id.
A horrible workaround but pure JPA.
Bite the bullet and create a simple class that provides the correct native SQL statement to use for the current environment and execute it via JdbcTemplate.
I'm new to DB2. Is there a way to query the tables to it will display the same data that STRPDM displays for a printed report (i.e.): Member, Type, Creation Date, Last Changed Date, Time, Records, Deleted Records, Text?
I'm not a DBA, but I have access to the SYSIBM schema (since I'm on the data team). I poked around the site and couldn't find a similar question.
Most of what you want is available in SYSPARTITIONSTAT. The way that source members are stored is unique to IBM i, and they aren't really a DB2 construct as such, although DB2 for i does keep limited information about source members modelled as partitions.
The IBM i way to get access to that information is through the RTVMBRD CL command or equivalent API. You can also see that via the DSPFD TYPE(*MBRLIST) command, which you can dump to a file via the OUTFILE() parameter and then query via SQL...
In CakePHP, we can provide recursive option while retrieving data from database, which automatically fetches the data from all the dependent tables.
We can also provide option for recursive e.g recursive=2, which fetches dependent tables of the dependent tables.
How can we achieve the same functionality in Zend framework?
If you have defined Table Relationship on your model before, you can use findDependentRowset() to retrieve records from multiple related table. For more details, see this.
But i am not sure of limiting the recursion.
I have multiple string values, I want to insert in an sql server db table, But i want to check values one by one if it already exist in the db I will update, if not I will insert it.
I am using Entity Framework 4.1, and I hope I can do that with best performance, means less calls to db as I can.
I saw this question before, but they are using linq to sql not entity framework.
One way you could do it is to batch up the queries for existence ... for example, using the .Contains method (like this), you can query for some or all of the items which may or may not exist at once. Then once you have the data locally, you can quickly check if it's there before inserting