I have native query stored in one of the tables and would like to fire the query. I have been looking for alternatives for Pure JDBC. my application has JPA capabilities.
Is there any framework or pattern to fire dynamic native queries?
Related
Suppose that I have an app where the models have been created using Django ORM and Django acts like an API for authentication and gives control to the relation model User using its ORM. At the same time, we want to use Express JS to continuously update a field in one the User model for some feature that requires performance. Is it possible to use a JavaScript ORM with Express JS to update such field? If yes, then how?
In the following tutorial tutorial for Golang, the database is created using SQL and a table called go_test_model is created. Then he uses the struct called GoTestModel to create a row in the table go_test_model.
This basically means that if we create an app called api in Django and add in it a model called Example, then to handle that model in Golang we just create a struct called ApiExample and from there we can have CRUD access to the same table, there might be some conflicts in the fields datatypes between GORM and Django ORM but integrity is still applied in the database itself.
So this particular example solves my problem with Golang and can be replicated using Node JS.
You can use Sequelize for using native functions for performing queries instead of writing raw queries.
Also, please refer to Models section to define models.
We are developing a razor application with VueJS on the frontend and razor / ASP.NET Core 5 on the backend. VueJS accesses the data via post (ajax) requests which we are handling using page handlers in the page models.
I have integrated Entity Framework and done a few queries for practice however I am realizing Entity Framework is not my answer. All of my SQL queries are saved as table valued functions in SQL Server and the update / insert / delete operations are done using stored procedures in SQL Server.
We have a SQL programmer so he just does everything server-side to keep things simple and just gives us function / procedure names and parameters.
I like this approach and we used this in our application when it was VBA in Excel using ADO and recordsets but now that we are using ASP.NET Core in a web setting so I am learning Entity Framework. However EF requires me to maintain models and that seems unnecessarily complicated as my SQL results are generated from procedures / functions.
Really I just need to run these procedures / functions and return the results as a json data array in the POST request.
What would be the best option for this in regards to performance and simplicity (hopefully they can go hand in hand)? A simple code example would also be helpful to get the ball rolling.
As for other questions on StackOverflow I have seen one question which is similar that says dapper is great for stored procedures but does not indicate if table valued functions are allowable.
Please note that Entity Framework Core also allows us to execute raw SQL query to make use of existing stored procedure. For more information about executing raw SQL queries with Entity Framework Core, you can check this doc:
https://learn.microsoft.com/en-us/ef/core/querying/raw-sql
Besides, if you want to implement it with ADO.NET approach, you can try to use Microsoft.Data.SqlClient that provides the data provider for Microsoft SQL Server.
https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/
I am using Mysql, Springboot with JPA Hibernate.
Now to query using JPA, I have 2-3 options:
Using functionNames as direct query like findById() and soon
Using JPQL
Using Native Query in my SpringBoot JPA Repository (using nativeQuery = true)
Using CustomRepo and then write SQL and fire query using Hibernate Entity Manager
Now what will be performance in all four cases?
I mean which method is most optimized and which is least and reason?
We are working on a sync application using ColdFusion 9.0.1 ActionScript ORM Library for AIR applications. Since this is application should work smoothly offline as well, there is a list of clients that has to be loaded when a user logs in, hence we are fetching data from all the required tables when application loads (is that the right way?). Now when we get the data from the required tables then based on the user who logs in we have to filter the clients, to filter this the query required is a complex one with joins between 5-6 tables and where clause. What I found that using the Coldfusion.Air.Session class we can only load objects of tables with simple where clause. There is non ORM way to load the data but I don't think that is the right method. Is there any method using this ORM framework to load data using such complex queries.
Thanks,
Gaurav
Are you using any CF code to send data back to your application? Have you tried HQL?
In other words you can write standard cfquery and dbtype="hql"
This will let you do almost anything you can do with a standard cfquery.
I am not directly familiar with the ActionScript ORM Library for AIR.
In the application I'm developing, I am using NHibernate as ORM.
My app has to support SQL Server, and MS Access (I'm using the NHibernate JetDriver).
Now, the thing is that I have a certain query which I cannot achieve using HQL or the ICriteria API; so, I'm using an ISQLQuery for that one.
Now, what bothers me, is that it seems that NHibernate is parsing the native SQL query as well, and thereby changing the SQL code of that query.
It seems that the specific Driver implementation is called, and my query is parsed; and in the case of the JetDRiver, the query is being modified by NHibernate which results in a query that is unexecutable.
So, why is it that NHibernate changes my native SQL queries ?
NHibernate does some changes even in native queries in order to be able to map the entities correctly.
My suggestion... download the JetDriver source from https://nhcontrib.svn.sourceforge.net/svnroot/nhcontrib/trunk/src/NHibernate.JetDriver/ and debug to see what's being broken. It might be a bug there.